Skip to content

[BUG] - MSSQL - bulkCreate on BigInt fields fails #15411

Closed

Description

@marra85

Issue Creation Checklist

  • I understand that my issue will be automatically closed if I don't fill in the requested information
  • I have read the contribution guidelines

Bug Description

Reproducible Example

Here is the link to the SSCCE for this issue:
sequelize/sequelize-sscce#242

What do you expect to happen?

the bulkCreate method should complete the operation.

What is actually happening?

The operation is failing because the bigint primitive is not well handled by the escape function in sql-string.js helper.

Adding a case statement on top of the existing number management would solve the issue because it will generate a correct SQL statement by removing the n at the end. (reference)

before

case 'number':
      return val.toString();

after

case 'bigint':
case 'number':
      return val.toString();

Environment

  • Sequelize version: 6.26.0
  • Node.js version: 14.20.0
  • If TypeScript related: TypeScript version: N\A
  • Database & Version: MSSQL 2016
  • Connector library & Version: tedious

Would you be willing to resolve this issue by submitting a Pull Request?

I can open a PR but I need assistance on how manage the automatic testing (if required)

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I will need guidance.
  • No, I don't have the time, but my company or I are supporting Sequelize through donations on OpenCollective.
  • No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in resolving my issue.

Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as "+1" will be removed.

Activity

  1. added
    type: feature
    on Dec 7, 2022
  2. ephys commented on Dec 7, 2022

    @ephys
    Member

    Just FYI, this is available in Sequelize 7 thanks to #14485 :)

    In the meantime, you can convert the bigint to a string, that's what sequelize used before bigint were a thing in JS

  3. marra85 commented on Dec 7, 2022

    @marra85
    Author

    Hello @ephys,

    thanks for the information!
    Sequelize 7 is still in alpha so it is not an option (for now) since our software is running in production.

    As for the conversion it will require us to modify the codebase in more than 100 functions to just to handle a cast that could be centralised on sequelize side.

    I'm available to open a PR if it will speedup the resolution :)

  4. ephys commented on Dec 7, 2022

    @ephys
    Member

    That would definitely speed things up :) If you're willing to port #14485 to our v6 branch, I'll make sure to review it in a timely manner

  5. added 2 commits that reference this issue on Dec 7, 2022
    90927ff
    413aa30
  6. github-actions commented on Dec 12, 2022

    @github-actions
    Contributor

    🎉 This issue has been resolved in version 6.27.0 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

  7. WikiRik commented on Dec 12, 2022

    @WikiRik
    Member

    Thanks for working on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    releasedtype: featurev6

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions