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 field is string in getterMethods

See original GitHub issue

I have the next model:

var Sequelize = require('sequelize');

module.exports = function () {
    return {
        attributes: {
            uuid            : Sequelize.STRING,
            ccc    : {type: Sequelize.BIGINT, allowNull: false},
            vvv   : Sequelize.BIGINT,
            bbb  : Sequelize.BIGINT
        },
        options: {
            getterMethods: {
                outstandingBalance: function() {
                    var ccc = this.ccc ? this.ccc : 0,
                        vvv = this.vvv ? this.vvv : 0,
                        bbb = this.bbb ? this.bbb : 0;

// the same if I do this.getDataValue('vvv') , I receive string as well

                    console.log(ccc, vvv, bbb);

                    return (ccc + vvv - bbb);
                }
            },
            classMethods: {},
            instanceMethods: {

            },
            tableName: 'xxx_calc'
        }
    };
};

Which produces the next to the console: image

The values are strings for some reason, however, if I would completely receive the model and print the value from the resolve method, the value of the ccc, vvv and bbb would be number.

I mean here:

YYY.find({ /* where */
                }).then(function (yyy) {
                    console.log(yyy.uuu.vvv);

                    return reply(yyy);
                });

Could you tell me how can I receive the number values in the getterMethods as well? Is that normal behaviour?

Regards,

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
janmeiercommented, Jul 28, 2015

It seems it’s strings all around in the example you posted? Which is as it should be, since bigint can’t reliably be stored in javascript ints, right? Accessing properties directly or with get also returns strings

0reactions
janmeiercommented, Jul 28, 2015
Read more comments on GitHub >

github_iconTop Results From Across the Web

getter - JavaScript - MDN Web Docs - Mozilla
The get syntax binds an object property to a function that will be called when that property is looked up. It can also...
Read more >
ResultSet (Java Platform SE 7 ) - Oracle Help Center
The ResultSet interface provides getter methods ( getBoolean , getLong , and so on) for retrieving column values from the current row.
Read more >
SqlType (Apache Calcite Avatica API)
Extends the information in Types . The information in the following conversions tables (from the JDBC 4.1 specification) is held in members of...
Read more >
Using basic JDBC data types - SQL Server - Microsoft Learn
bigint, BIGINT, long. binary, BINARY, byte[]. bit, BIT, boolean. char, CHAR, String. date, DATE, java.sql.Date.
Read more >
Mapping SQL and Java Types
Conversely, when a String object is sent to a CHAR(n) field, the driver and/or the ... The recommended Java mapping for the BIGINT...
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