Skip to content

User defined number types not serialized properly #10491

@gabegorelick

Description

@gabegorelick

What are you doing?

const User = this.sequelize.define('user', {
  age: Sequelize.BIGINT
});

const age = BigInt(Number.MAX_SAFE_INTEGER).add(Number.MAX_SAFE_INTEGER);

return User.sync({force: true}).then(() => {
  return User.create({age});
}).then(user => {
  expect(BigInt(user.age).toString()).to.equal(age.toString());
  return User.findAll({
    where: {age}
  });
}).then(users => {
  expect(users).to.have.lengthOf(1);
  expect(BigInt(users[0].age).toString()).to.equal(age.toString());
});

What do you expect to happen?

Sequelize serializes the BigInt as a string and generates valid SQL.

What is actually happening?

SequelizeDatabaseError: invalid input syntax for integer: ""18014398509481982""

Dialect: any (but tested on PG)
Dialect version: any
Database version: any
Sequelize version: master
Tested with latest release: yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions