Skip to content
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

Why smallint is mapped to int32 by default? #1152

Closed
eeczw opened this issue May 23, 2024 · 1 comment
Closed

Why smallint is mapped to int32 by default? #1152

eeczw opened this issue May 23, 2024 · 1 comment

Comments

@eeczw
Copy link

eeczw commented May 23, 2024

"smallint": func(string) string { return "int32" },

I searched in Postgres docs and MySQL docs and found out that both of their smallint types hava a storage size of 2 bytes. So I'm wondering why smallint is currently mapped to int32 by default. Will int16 be a better choice?

@eeczw eeczw changed the title Why smallint type is mapped to int32 by default? Why smallint is mapped to int32 by default? May 23, 2024
@qqxhb
Copy link
Member

qqxhb commented Jun 17, 2024

The default type is determined based on business usage; generally, int16 is rarely used, and more int32 is used.
If it does not meet your needs, you can configure it through Data Mapping.
https://gorm.io/gen/database_to_structs.html#Data-Mapping

@qqxhb qqxhb closed this as completed Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants