Skip to content
Advertisement

Out of range value for column ‘ownerid’ at row 1 node.js sql query

I am using a mysql pool here and I did a query inside of a query. This is supposed to save the guildowner ID in the database when this command is run. Unfortunately it does not let me run this code for some reason. I listed the error down below.

var mysql = require("mysql");
var pool  = mysql.createPool({
  connectionLimit : 10,
  host            : 'localhost',
  user            : '',
  password        : '',
  database        : ''
});
exports.run = (client, message, args) => {
 var oid = message.guild.owner.id;
 var sql = `SELECT * from esite WHERE ownerid = ${message.guild.owner.id}`;
 pool.query(sql,  function (err, row) {
     if(err) throw err;
        if (row && row.length ) {
            console.log('Case row was found!');
            // do something with your row variable
        } else {
            console.log('No case row was found :( !');
               var sql2 = `INSERT INTO esite (ownerid) VALUES ?`;
               var values = [
                [`${message.guild.owner.id}`]
                ];
                pool.query(sql2, [values], function (err) {
                     if(err) throw err;
                   });
        }
    });
}

Error:

Error: ER_WARN_DATA_OUT_OF_RANGE: Out of range value for column 'ownerid' at row 1
    at Query.Sequence._packetToError (/root/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
    at Query.ErrorPacket (/root/node_modules/mysql/lib/protocol/sequences/Query.js:79:18)
    at Protocol._parsePacket (/root/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (/root/node_modules/mysql/lib/protocol/Parser.js:433:10)
    at Parser.write (/root/node_modules/mysql/lib/protocol/Parser.js:43:10)
    at Protocol.write (/root/node_modules/mysql/lib/protocol/Protocol.js:38:16)
    at Socket.<anonymous> (/root/node_modules/mysql/lib/Connection.js:88:28)
    at Socket.<anonymous> (/root/node_modules/mysql/lib/Connection.js:526:10)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:302:12)
    --------------------
    at Pool.query (/root/node_modules/mysql/lib/Pool.js:199:23)
    at Query.<anonymous> (/root/dc/DHL/commands/esite.js:23:22)
    at Query.<anonymous> (/root/node_modules/mysql/lib/Connection.js:526:10)
    at Query._callback (/root/node_modules/mysql/lib/Connection.js:488:16)
    at Query.Sequence.end (/root/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
    at Query._handleFinalResultPacket (/root/node_modules/mysql/lib/protocol/sequences/Query.js:149:8)
    at Query.EofPacket (/root/node_modules/mysql/lib/protocol/sequences/Query.js:133:8)
    at Protocol._parsePacket (/root/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (/root/node_modules/mysql/lib/protocol/Parser.js:433:10)
    at Parser.write (/root/node_modules/mysql/lib/protocol/Parser.js:43:10) {
  code: 'ER_WARN_DATA_OUT_OF_RANGE',
  errno: 1264,
  sqlMessage: "Out of range value for column 'ownerid' at row 1",
  sqlState: '22003',
  index: 0,
  sql: "INSERT INTO esite (ownerid) VALUES ('407206318911258628')"
}

Advertisement

Answer

The largest integer value allowed in mySQL int data type is 4294967295.

If you change the data type to BIGINT, your value will work.

See this page for details

https://www.mysqltutorial.org/mysql-int/

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement