go-enum
go-enum copied to clipboard
questions about empty strings
Two questions about empty strings:
- Enumeration values currently do not support empty strings? (because there is a valid empty string case)
- The mysql type is varchar, default: "". In this case, the Scanner and Valuer interfaces can only be implemented manually?
Do you mind expanding on the use case for an empty string enum value?
And if you need to implement a different sql/valuer interface methods, you can create a custom template and have the tool use that for your use case if the provided one doesn't do the right thing for you.
I think "" maybe is useful for some table schema design like varchar, which is don't want to be null,
sometimes is easier for programing dont need deal with null
+1
+1
With the addition of string enums, you should be able to do this by adding an entry empty = "", or whatever you want to call it.
Let me know if this doesn't work for you.
You mean ENUM(empty = "", value1) ?
Is is not parsed
failed parsing the data part of enum value 'empty = ""': strconv.ParseUint: parsing """": invalid syntax
I mean
//ENUM(empty="", value1)
type TestEnum string
The use case in question is about parsing empty strings as part of SQL, which would assume that there is no need for an integer part, so simply using strings would solve the problem at hand.
Thanks again for the interest in the project... I'm going to close this ticket now, but if you have troubles with it still... please either reopen or open a new ticket and I'll see what I can do to resolve it for you.
Thanks!