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
{{ message }}
Repository navigation
Correct db_type for overriding integers is confusing #421
Due to the SQL parser we use for Postgres, the column type is automatically converted into a canonical format. In this case, it translates integer to pg_catalog.int4. The correct configuration file is this:
On the subject of others string types, the Postgres type TEXT is correctly overridden with db_type: "text"
The initial issue alongside with the varchar one makes me think that other types too might not be recognized correctly without the pg_catalogue representation. Maybe an endtoend test should be added to check that all Postgres types are correctly recognized? Anyway I suppose it's a relatively low priority issue.
If I remove the nullable: true or set it to false then it reverts back to pgtype.Numeric.
Fwiw, it would also be very helpful to get warnings when an overridden db_type can't be overridden with the provided go_type. Though maybe a numeric than can be null is not considered the same as a numeric not null.
Apologies, it seems I spoke too soon. I just discovered the github.com/shopspring/decimal package has a NullDecimal type that parses perfectly for this purpose. I'll leave my comment in case anyone finds it helpful.
Activity
maxiride commentedon May 6, 2020
I've encountered this issue too with the db_type
VARCHAR.Given the schema
the correct override configuration is:
On the subject of others string types, the Postgres type
TEXTis correctly overridden withdb_type: "text"The initial issue alongside with the varchar one makes me think that other types too might not be recognized correctly without the pg_catalogue representation. Maybe an endtoend test should be added to check that all Postgres types are correctly recognized? Anyway I suppose it's a relatively low priority issue.
henrybaxter commentedon Dec 13, 2020
I would add that overriding
decimalis also confusing, for example in my particular case I had:and the correct override for me was:
Posting for anyone else who may come across it - thanks for the awesome project!
fpieper commentedon Aug 9, 2022
Maybe something has changed, but I needed to specify the exact type
Decimalrenanferr commentedon Dec 13, 2023
For the record, to override
smallinttype I had to do:cmarkh commentedon Jan 2, 2024
Do you know if there is a way to override a
numerictype that can benull?The following works for me but then it doesn't handle the null case.
If I remove the
nullable: trueor set it tofalsethen it reverts back topgtype.Numeric.Fwiw, it would also be very helpful to get warnings when an overridden db_type can't be overridden with the provided go_type. Though maybe a numeric than can be null is not considered the same as a
numeric not null.Thanks for the amazing package!
cmarkh commentedon Jan 2, 2024
Apologies, it seems I spoke too soon. I just discovered the
github.com/shopspring/decimalpackage has a NullDecimal type that parses perfectly for this purpose. I'll leave my comment in case anyone finds it helpful.