Skip to content

fix(boilingcore): use conventional camelCase for struct tag casing - #1470

Closed
KeitaShimura wants to merge 1 commit into
aarondl:masterfrom
KeitaShimura:fix/camel-case-no-initialisms-for-struct-tags
Closed

fix(boilingcore): use conventional camelCase for struct tag casing#1470
KeitaShimura wants to merge 1 commit into
aarondl:masterfrom
KeitaShimura:fix/camel-case-no-initialisms-for-struct-tags

Conversation

@KeitaShimura

Copy link
Copy Markdown
Contributor

Summary

When json = "camel" (or any tag format set to camel) is configured, SQLBoiler
was using strmangle.CamelCase which follows Go's initialism convention. This
caused column names like account_id to be rendered as accountID in struct
tags, whereas the conventional camelCase for JSON APIs is accountId.

This PR introduces camelCaseNoInitialisms in boilingcore/templates.go and
uses it in generateTagWithCase for TagCaseCamel instead of
strmangle.CamelCase.

Changes

  • boilingcore/templates.go: Add camelCaseNoInitialisms which converts
    snake_case to camelCase by title-casing only the first letter of each word,
    without uppercasing common Go initialisms (e.g. ID, URL). Update
    generateTagWithCase to use this function for TagCaseCamel.
  • boilingcore/templates_test.go: Add TestCamelCaseNoInitialisms and
    TestGenerateTagWithCaseCamel to verify the new behaviour.

Behaviour change

Column name Before (broken) After (fixed)
account_id accountID accountId
http_url httpURL httpUrl
column_name_id columnNameID columnNameId

Note: This is a breaking change for users who were relying on the previous
(Go-initialism) output. However, the previous output did not conform to JSON
camelCase conventions, so this is considered a bug fix.

Related issue

Related to #1411

@stephenafamo

Copy link
Copy Markdown
Collaborator

This will be a breaking change which is unacceptable

@KeitaShimura
KeitaShimura deleted the fix/camel-case-no-initialisms-for-struct-tags branch May 27, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants