Skip to content

Conversation

@jwc-clinnection
Copy link
Contributor

If json_tags_id_camelcase is true, "ID" in json tags will be camelcase. If false, will be uppercase. Defaults to false

Example where false:

type Example struct {
	ID           uuid.UUID  `json:"id"`
	Name         string     `json:"name"`
	CreatedAt    time.Time  `json:"createdAt"`
	UpdatedAt    time.Time  `json:"updatedAt"`
	CreatedByID  *uuid.UUID `json:"createdByID"`
	UpdatedByID  *uuid.UUID `json:"updatedByID"`
}

Example where true:

type Example struct {
	ID           uuid.UUID  `json:"id"`
	Name         string     `json:"name"`
	CreatedAt    time.Time  `json:"createdAt"`
	UpdatedAt    time.Time  `json:"updatedAt"`
	CreatedByID  *uuid.UUID `json:"createdById"`
	UpdatedByID  *uuid.UUID `json:"updatedById"`
}
If json_tags_id_camelcase is true, "ID" in json tags will be camelcase.
If false, will be uppercase. Defaults to `false`
@Killian-Grieg
Copy link

I need this so much! Thank you

@kyleconroy
Copy link
Collaborator

Discussed this a bit with Andrew, I think we want to go ahead and making a breaking change here. By default, I think we want updated_by_id to map to updatedById. Let's rename the configuration option to be json_tags_id_uppercase and output updatedByID when that's true.

If true, "Id" in json tags will be uppercase. If false, will be camelcase. Defaults to `false`
@jwc-clinnection
Copy link
Contributor Author

Discussed this a bit with Andrew, I think we want to go ahead and making a breaking change here. By default, I think we want updated_by_id to map to updatedById. Let's rename the configuration option to be json_tags_id_uppercase and output updatedByID when that's true.

I have pushed the requested changes.

@kyleconroy kyleconroy merged commit e1e5ed6 into sqlc-dev:main Jun 21, 2023
alfonsodev pushed a commit to ExponentiaTeam/sqlc that referenced this pull request Oct 13, 2025
* Add json_tags_id_camelcase configuration option

If json_tags_id_camelcase is true, "ID" in json tags will be camelcase.
If false, will be uppercase. Defaults to `false`

* json_tags_id_uppercase

If true, "Id" in json tags will be uppercase. If false, will be camelcase. Defaults to `false`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants