Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

282
Views
How can I stop rounding int values in MySQL

I am a discord bot developer. I am trying to use MySQL for my discord bot. I am trying to save guild ids in my table. Guild ids rounding automatically when I post to table. Forexample my guild id is 837465019283745861. It is posting like 837465019283745900. I am using mysql module.

My Table:

CREATE TABLE guilds (
id INT PRIMARY KEY AUTO_INCREMENT,
guild_id BIGINT(18) NOT NULL);

My Post Code:

const guild = 837465019283745861;
connection.query('INSERT INTO guilds (guild_id) VALUES (?)', guild, function(error, results, fields) {
    if (error) throw error;
    console.log('Data sent!');
});
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Those values don't get rounded in MySQL. That's JavaScript screwing with you because you're not using BigInt:

const guild = 837465019283745861n;

All numbers in JavaScript are actually floating point unless otherwise specified. This leads to rounding on larger numbers.

over 4 years ago · Santiago Trujillo Report

0

To solve this, add 'supportBigNumbers' to your MySQL con

Example:

const database = {
  host: env.db_host,
  port: env.db_port,
  user: env.db_user,
  password: env.db_password,
  database: env.db_name,
  supportBigNumbers: true // BigInt not rounded now
};

See more on: https://www.npmjs.com/package/mysql#getting-the-id-of-an-inserted-row

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!