相关文章推荐

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

As the title says, I'm a bit curious to why a bool field is translated to a tinyint field?

I've only seen this for MySQL/MariaDB so I don't know if this is present in Postgres for example.

The bool type in most databases is an alias for tinyint (which makes sense) but it can be semantically confusing to use tinyint instead of bool when creating the column.

Which "resulting tinyint field" are you commenting on?

Are you referring to table columns created by gorm?
Then as you noted, bool is just an alias in mysql for tinyint (there is no such thing as a bool in a mysql database).

its the smallest int that can be 0 or greater.. all db's do it in different flavours efficiently, dont painic
it could be a null .. krash

https://stackoverflow.com/questions/18872023/what-is-the-best-data-type-to-store-boolean-values-in-a-database

 
推荐文章