question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bigint rounding issue in postgresql

See original GitHub issue

Confirm by changing [ ] to [x] below to ensure that it’s a bug:

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)

  1. create a table with bigint datatype in PostgreSQL
  2. insert data from PostgreSQL (psql)
  3. 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:closed
    • Created 4 years ago
    • Reactions:1
    • Comments:6 (2 by maintainers)

    github_iconTop GitHub Comments

    1reaction
    kpbirdcommented, Nov 12, 2020

    Hello

    The issue is not fixed yet

    0reactions
    github-actions[bot]commented, Mar 4, 2022

    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.

    Read more comments on GitHub >

    github_iconTop Results From Across the Web

    Postgresql BIGINT to Double Precision division rounding issue
    Your 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 - PostgreSQL
    Values 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 PostgreSQL
    Problem : 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 >

    github_iconTop Related Medium Post

    No results found

    github_iconTop Related StackOverflow Question

    No results found

    github_iconTroubleshoot Live Code

    Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
    Start Free

    github_iconTop Related Reddit Thread

    No results found

    github_iconTop Related Hackernoon Post

    No results found

    github_iconTop Related Tweet

    No results found

    github_iconTop Related Dev.to Post

    No results found

    github_iconTop Related Hashnode Post

    No results found