You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BalanceTestTab struct {
Id int64 `db:"id"`
Balance int64 `db:"balance"`
}
Expected behavior
the Balance should be *big.Int, but it is generated a int64 field
And if I modify the bigint types_map, fields id bigserial and balance numeric(78) both be generated to *big.Int, which indicated that numeric data type of PostgreSQL is always treated as bigint
there is a function convertPostgreSqlTypeIntoMysqlType and variable p2m who convert numeric of postgreSQL to bigint of MySQL, I think it is not reasonable, numeric of postgreSQL is almost equal to decimal of MySQL, both are used for accurate large number, so the value of key "numeric" in var p2m should be "decimal"
source code:
func (m *PostgreSqlModel) convertPostgreSqlTypeIntoMysqlType(in string) string {
r, ok := p2m[strings.ToLower(in)]
if ok {
return r
}
return in
}
Describe the bug
numeric data type of PostgreSQL has been treated as bigint, no matter what config I use, the config not worked
To Reproduce
goctl version 1.7.5
PostgreSQL DDL
goctl.yaml
result
Expected behavior
the Balance should be *big.Int, but it is generated a int64 field
And if I modify the bigint types_map, fields id bigserial and balance numeric(78) both be generated to *big.Int, which indicated that numeric data type of PostgreSQL is always treated as bigint
Logic in source code
I found in
https://github.com/zeromicro/go-zero/blob/master/tools/goctl/model/sql/model/postgresqlmodel.go
there is a function convertPostgreSqlTypeIntoMysqlType and variable p2m who convert numeric of postgreSQL to bigint of MySQL, I think it is not reasonable, numeric of postgreSQL is almost equal to decimal of MySQL, both are used for accurate large number, so the value of key "numeric" in var p2m should be "decimal"
source code:
Screenshots
![Image](https://private-user-images.githubusercontent.com/32705367/410067006-ccd0a24f-a2f7-4ff3-ae1a-c09b6a7a680b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNjkyOTIsIm5iZiI6MTczOTM2ODk5MiwicGF0aCI6Ii8zMjcwNTM2Ny80MTAwNjcwMDYtY2NkMGEyNGYtYTJmNy00ZmYzLWFlMWEtYzA5YjZhN2E2ODBiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDE0MDMxMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU2NThlZTIyMDJlOTVjNjVkYzgxMjhmNDYwOWFiYzY0M2UyMzYxNTJkMjkxOGM4NjI1ODc1ZmM3ZjNiMzc5ZmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.My_thSx9LOB1aCWZLliK6GdrervgnSKF40DjkmUkBDw)
Environments:
The text was updated successfully, but these errors were encountered: