Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add json_tags_id_camelcase configuration option #2325

Merged
merged 2 commits into from
Jun 21, 2023

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
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.

3 participants