Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing for QueryInterface's bulkInsert & bulkUpdate attributes parameter is incorrect #13466

Closed
3 of 8 tasks
aryem opened this issue Aug 28, 2021 · 0 comments
Closed
3 of 8 tasks
Labels
type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense.

Comments

@aryem
Copy link
Contributor

aryem commented Aug 28, 2021

Issue Creation Checklist

Bug Description

SSCCE

// You can delete this code block if you have included a link to your SSCCE above!
const { createSequelizeInstance } = require('./dev/sscce-helpers');
const { Model, DataTypes } = require('.');
import { QueryInterface } from 'sequelize';

const sequelize = createSequelizeInstance({ benchmark: true });

class User extends Model {}
User.init({
  username: DataTypes.STRING,
  birthday: DataTypes.DATE
}, { sequelize, modelName: 'user' });

(async () => {
  await sequelize.sync({ force: true });

   const queryInterface: QueryInterface = sequelize.getQueryInterface();

   // Gives typying error because attributes type is string[] | string, but that is not correct.  
  await queryInterface.bulkUpdate("user", {}, {}, {}, attributes);
 await queryInterface.bulkInsert("user", {}, {}, {}, attributes);
  
  await sequelize.close();
})();

What do you expect to happen?

The type of attributes parameter is incorrect for bulkInsert & bulkUpdate.

  • Currently, the type of attributes is string[] | string | undefined but it should be of type object.
  • Query interface API docs

Screenshot 2021-08-29 at 12 46 37 AM

Screenshot 2021-08-29 at 12 59 46 AM

Environment

  • Sequelize version: v6.6.5
  • Node.js version: 14.16.1
  • If TypeScript related: TypeScript version: 3.9.6

Bug Report Checklist

How does this problem relate to dialects?

  • I think this problem happens regardless of the dialect.
  • I think this problem happens only for the following dialect(s):
  • I don't know, I was using PUT-YOUR-DIALECT-HERE, with connector library version XXX and database version XXX

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

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I don't know how to start, I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.
aryem added a commit to aryem/sequelize that referenced this issue Aug 28, 2021
 change attributes type to 'object':
 - attributes param in QueryInterface.bulkInsert() change to 'object | undefined' from 'string[] | string | undefined'.
 - attributes param in QueryInterface.bulkUpdate() change to 'object | undefined' from 'string[] | string | undefined'.
 - add '{}' as last param in bulkInsert() & bulkUpdate() tests

 Closes sequelize#13466
aryem added a commit to aryem/sequelize that referenced this issue Aug 28, 2021
 change attributes type to 'object':
 - attributes param in QueryInterface.bulkInsert() change to 'object | undefined' from 'string[] | string | undefined'.
 - attributes param in QueryInterface.bulkUpdate() change to 'object | undefined' from 'string[] | string | undefined'.
 - add '{}' as last param in bulkInsert() & bulkUpdate() tests

Closes sequelize#13466
@wbourne0 wbourne0 added the type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense. label Oct 3, 2021
@github-actions github-actions bot added stale and removed stale labels Oct 27, 2021
@github-actions github-actions bot added the stale label Nov 4, 2021
@WikiRik WikiRik removed the stale label Nov 15, 2021
@aryem aryem closed this as completed Feb 5, 2024
@sequelize sequelize deleted a comment from github-actions bot Feb 8, 2024
@sequelize sequelize deleted a comment from github-actions bot Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants