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

Postgres bigint's are converted to Number and lose precision #10

Open
willrust opened this issue Jun 13, 2023 · 0 comments
Open

Postgres bigint's are converted to Number and lose precision #10

willrust opened this issue Jun 13, 2023 · 0 comments

Comments

@willrust
Copy link

dialects/postgres.parser.ts assigns a type of 'number' to 'bigint' column types in the getColumnType switch. here

adminjs/src/utils/param-converter/convert-param.ts then references this 'number' type and converts the value to a Number() which loses precision. here

Returning 'bigint' for case 'bigint' at least allows the value to remain a string and maintain precision with the current convert-param.ts, but I suppose a conversion to BigInt() would be possible there.

This is breaking show and edit actions with bigint id columns that lose precision and query the wrong id.

As a way around this, I attempted to define bigint resource id properties as type: 'string' in the AdminJS constructor options, but this only fixed the show action. I was hoping that defining the type there might override the type in the Resource, but it doesn't work that way. I'm actually not sure why it does work for the show action.

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

1 participant