-
Notifications
You must be signed in to change notification settings - Fork 550
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
Map mysql tinyint to golang bool #80
Comments
Hi @deafwolf, have you tried setting the type as BOOL or BOOLEAN in MySQL? I realize that they're synonyms for TINYINT(1), but I can't recall if our MySQL schema analysis query gets the alias type or the underlying type. We do have this in the structs:
So if a type of BOOL or BOOLEAN in your MySQL database is not working for you then this would potentially be considered a bug (providing we can get the alias type from MySQL). Anyway, that'd be my first suggestion. Let me know if that does the trick or not. Thanks. |
@nullbio Thank you for your suggestion. When I created table with "alive boolean", then ran |
@deafwolf Thanks, and fair enough. Yeah, this is something we'll have to consider for MySQL. From what I gather, the problem with this is that |
@nullbio Thanks, what about use a --tinyint-to-bool flag with 2.1.4 to avoid make a breaking change? |
Haha, was just writing up a response with that idea as you said that. We'll add |
👍 |
@deafwolf This has now been released https://github.com/vattle/sqlboiler/releases/tag/v2.1.4 -- Let me know if you run into any problems. Thanks. |
Actually, I'll leave this issue open as a reminder that the default value and flag name should change in v3.0.0. |
I have updated to 2.1.4 and worked fine, thanks. |
Flag is now removed. Uses |
Hmm. Looks like it's generated as int8 now. Could this be related to mariadb? |
Ok, found it. Mysql workbench converted BOOLEAN to TINYINT but source code is mapped to
So when I've changed TINYINT to TINYINT(1) it converted to bool 👍 |
I couldnt find a list of all possible configurations for |
Here is a list of generic configuration options: https://github.com/volatiletech/sqlboiler/tree/master#generic-config-options Seems like |
I have create a table like this
Then sqlboiler generate the golang model like this
What I want is
I change the int8 to bool manually, looks sqlboiler work good.
Is there a way change int8 to bool automatically?
The text was updated successfully, but these errors were encountered: