-
Notifications
You must be signed in to change notification settings - Fork 57
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
Possible improvement for Scanner with sqlint flag #239
Comments
@iamthenoname321 Great question! I don't remember off the top of my head, but I'll look into seeing if there's a way to reduce that generated code. I'm also open to a PR if you have the time 😉 😉 |
Alright, I'll try to work on it on my spare time. Thanks! |
The // these functions do the exact same thing
func NewNullEnum(val interface{}) (x NullEnum) {
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
return
}
func NewNullEnumStr(val interface{}) (x NullEnumStr) {
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
return
} I noticed that this is only one of many issues related to the inconsistency between the four SQL flags. Mainly:
I think an entire overhaul of the SQL code generation is needed. I'd like to hear your opinion on this. |
Right now, go-enum generates a massive switch statement when using string enums with the flag
--sqlint
. This is mostly because the switch checks for nil values and integer types other thanint64
.gocyclo
reports a score of 25, which could be a problem for https://goreportcard.com that wants a minimum gocyclo score of 15.However, the documentation for sql.Scanner states this:
I'm a bit confused as to why go-enum has to check for other types such as
int
anduint64
. Is it necessary?The text was updated successfully, but these errors were encountered: