How do I tell sqlc to omit a field in the json if it's empty #1132
Unanswered
adityaladwa
asked this question in
Q&A
Replies: 2 comments
-
@adityaladwa do you have a solution now? |
Beta Was this translation helpful? Give feedback.
0 replies
-
I have opened a PR for adding support for |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Discussed in #1087
Originally posted by adityaladwa July 14, 2021
Let's say I have a table
After I run
sqlc generate
the following model will be generated:I would like to omit the description if it's empty (as it's a nullable column).
Now, I can use column override and use
string
type instead ofsql.NullString
. So now the generated type will beThe problem with this is that if Description is
nil
, it won't be omitted from thejson
response. So the response would be something like this:Is there a way I can tell
sqlc
to addomitempty
tag to a particular field? (Description field in this case)Any other way to solve this issue?
Beta Was this translation helpful? Give feedback.
All reactions