bigint rounding issue in postgresql
See original GitHub issueConfirm by changing [ ] to [x] below to ensure that it’s a bug:
- I’ve gone though Developer Guide and API reference
- I’ve checked AWS Forums and StackOverflow for answers
- I’ve searched for previous similar issues and didn’t find any solution
Describe the bug I am using postgresql serverless with bigint as primary key (id), when I try to insert or select bigint value node js sdk does rounding
Is the issue in the browser/Node.js? Node.js
If on Node.js, are you running this on AWS Lambda? Yes
Details of the browser/Node.js version v10.15.0
SDK version number aws-sdk@2.568.0
To Reproduce (observed behaviour)
- create a table with bigint datatype in PostgreSQL
- insert data from PostgreSQL (psql)
- use data API to retrieve data (select * from
)
** Wrong Response **
{ "numberOfRecordsUpdated": 0, "records": [ [ { "longValue": **2116623750278415400** }, { "stringValue": "KP" }, { "stringValue": "KP" }, { "stringValue": "2019-08-23 06:20:35.236881" }, { "stringValue": "2019-08-23 06:20:35.236881" }, { "longValue": -1 }, { "longValue": -1 }, { "booleanValue": false }, { "longValue": 1 }, { "booleanValue": true } ] ] }
Expected behavior
{ "numberOfRecordsUpdated": 0, "records": [ [ { "longValue": **2116623750278415361** }, { "stringValue": "KP" }, { "stringValue": "KP" }, { "stringValue": "2019-08-23 06:20:35.236881" }, { "stringValue": "2019-08-23 06:20:35.236881" }, { "longValue": -1 }, { "longValue": -1 }, { "booleanValue": false }, { "longValue": 1 }, { "booleanValue": true } ] ] }
Additional context full source code
const AWS = require('aws-sdk') const RDS = new AWS.RDSDataService({ "region": "eu-west-1" }) var DBSecretsStoreArn = "<ARN>" var DBAuroraClusterArn = "<ARN>"; var DatabaseName = "<DB NAME>"; var select = "select * from <TABLE NAME>" var sqlStatement = select async function test() { const params = { secretArn: DBSecretsStoreArn, resourceArn: DBAuroraClusterArn, sql: sqlStatement, database: DatabaseName, includeResultMetadata: true } try { data = await RDS.executeStatement(params).promise() console.log(data.records[0]) } catch (err) { console.log(err) } } test()
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Postgresql BIGINT to Double Precision division rounding issueYour problem is that 10^18 is a double, so then dividing your int by that double leaves you with a double. For the...Read more >Documentation: 15: 8.1. Numeric Types - PostgreSQLValues that are too large or too small will cause an error. Rounding might take place if the precision of an input number...Read more >How to prevent PostgreSQL from automatically rounding ...In this case, I have lost precision. I entered five decimal places, but Postgres automatically rounded down to four. I want this to...Read more >Floating-point rounding errors in UI for very large integers (JS ...Metabase is unable to display the large numbers as answers, and appears to round them off when displaying them. Among other issues, this...Read more >How to Convert a String to a Numeric Value in PostgreSQLProblem : You'd like to convert a string to a decimal value in PostgreSQL. Let's convert the value in a string to a...Read more >Top Related Medium Post
No results foundTop Related StackOverflow Question
No results foundTroubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.Start FreeTop Related Reddit Thread
No results foundTop Related Hackernoon Post
No results foundTop Related Tweet
No results foundTop Related Dev.to Post
No results foundTop Related Hashnode Post
No results found - State:
Hello
The issue is not fixed yet
Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.