-
Notifications
You must be signed in to change notification settings - Fork 802
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
autogenerate enum validation methods #1607
Labels
Comments
josharian
added
enhancement
New feature or request
triage
New issues that hasn't been reviewed
labels
May 10, 2022
On a related note, I find myself wanting to be able to list all available enum values. |
I have definitely opened a ticket for this previously, probably at least a
year ago, agree it would be a good feature
On Wed, May 11, 2022 at 11:19 Josh Bleecher Snyder ***@***.***> wrote:
On a related note, I find myself wanting to be able to list all available
enum values.
—
Reply to this email directly, view it on GitHub
<#1607 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AML53FNE33JXEDCEZBJZC5DVJP22BANCNFSM5VST2BLA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
--
Kevin Burke
phone: 925-271-7005 | kevin.burke.dev
|
josharian
added a commit
to josharian/sqlc
that referenced
this issue
May 11, 2022
This commit adds a Valid method for enum types and an All...Values function to get all enum values. This makes it easier to work with enums. Fixes sqlc-dev#1607
josharian
added a commit
to josharian/sqlc
that referenced
this issue
May 11, 2022
This commit adds a Valid method for enum types and an All...Values function to get all enum values. This makes it easier to work with enums. Fixes sqlc-dev#1607
The fix was easy: #1613. Feedback welcome. I hope we can get it reviewed. |
kyleconroy
added
🔧 golang
and removed
triage
New issues that hasn't been reviewed
labels
May 12, 2022
Ah, previously here: #447 I still think this is a good idea. |
josharian
added a commit
to josharian/sqlc
that referenced
this issue
May 12, 2022
This commit adds a Valid method for enum types and an All...Values function to get all enum values. This makes it easier to work with enums. These are gated by new config parameters emit_enum_valid_method and emit_all_enum_values. Fixes sqlc-dev#1607
josharian
added a commit
to josharian/sqlc
that referenced
this issue
May 12, 2022
This commit adds a Valid method for enum types and an All...Values function to get all enum values. This makes it easier to work with enums. These are gated by new config parameters emit_enum_valid_method and emit_all_enum_values. Fixes sqlc-dev#1607
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What do you want to change?
The codegen for enums generates a list of constants containing valid values:
When writing developer tools, it can be helpful to convert from a string value to an enum type. However, there is no exhaustive list of valid enum values, so we have to wait until a query fails to discover that an invalid enum value has been provided.
I'd like the codegen to also emit something like:
Then I can convert from string to enum type and check valid early on.
I know that this applies to PostgreSQL and Go. I'm not sure about MySQL and the other languages.
What database engines need to be changed?
PostgreSQL
What programming language backends need to be changed?
Go
The text was updated successfully, but these errors were encountered: