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

bug:numeric pgsql numbers read incorrectly when read in/passed along #5325

Open
Filmtangent opened this issue Feb 18, 2025 · 2 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@Filmtangent
Copy link

Describe the bug

Hi,

I'm having an interesting issue. I am reading from a database that uses a numeric field with large numbers in it (to the order of 1.8 x 10^18).
These numbers are written in by a Postgres script in a flow.

When accessing them in another flow, reading from the same table in another Postgres script the values are coming back rounded to the nearest hundred, if forced to show a more detailed value (for example using x.toFixed(0)) the number shows a shift. I assume this is a conversion error under the hood but I'm not sure where it's coming from.

The rounded number is what comes back in the json result of the Postgres query.

I'll provide examples for the particular example I am working with.

To reproduce

have a Postgres database with a "numeric" typed data column, with a large number.
e.g.
cell value:
1909198862420847982

attempt to read from that value from the database
select * from projects;

1909198862420847900

project_id.toFixed(0)

1909198862420847872

Expected behavior

The value returned from the Postgres query should be exactly what it is in the database.

Screenshots

Here are screenshots from a sql table gui, windmill's Postgres script and a subsequent bun script showing the result of various manipulation to the return value.

Image
Image
Image

Browser information

No response

Application version

No response

Additional Context

running windmill CE v1.465.0

@Filmtangent Filmtangent added the bug Something isn't working label Feb 18, 2025
@Filmtangent
Copy link
Author

Filmtangent commented Feb 19, 2025

my current work around is to create a new column where the number is forced to bigint (BigInt(xxxxxx)) and then encoded to base64 for it to then be pulled after, this is of course not ideal

@HugoCasa HugoCasa assigned HugoCasa and unassigned rubenfiszel Feb 19, 2025
@HugoCasa
Copy link
Contributor

It's actually not specific to Postgres but because the frontend (javascript) can't handle numbers that are too big (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER).
We're adding a warning for now (#5340) and we will improve in a future PR how we parse the JSON result to convert large integers to bigint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants