Skip to content

Increment with object does not respect field names #12512

@eirikurn

Description

@eirikurn

Issue Description

When incrementing multiple fields using the object syntax, the field names are not transformed (eg to underscore), causing an error since the column doesn't exist. This is a regression from version 5.

What are you doing?

class MyModel extends Model {}
MyModel.init({
  works: {
    type: DataTypes.INTEGER,
    defaultValue: 0,
  },
  longerField: {
    type: DataTypes.INTEGER,
    defaultValue: 0,
  },
}, {
  sequelize,
  modelName: 'MyModel',
  underscored: true,
})

await MyModel.increment({
  works: 1,
  longerField: 1,
});
// SequelizeDatabaseError column "longerField" does not exist

// While this works:
await MyModel.increment("longerField")
await MyModel.increment(["works", "longerField"])

What do you expect to happen?

It should convert to the correct field names and increment the right columns.

What is actually happening?

We get a SequelizeDatabaseError column "longerField" does not exist

Environment

  • Sequelize version: 6.3.3
  • Node.js version: 12.18.2
  • Operating System: OSX 10.15.4

Issue Template 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugDEPRECATED: replace with the "bug" issue type

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions