Skip to content

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

@willrust

Description

@willrust

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions