Skip to content

Model:destroy does not use the real 'field' name. #11112

Closed

Description

@MarceloAplanalp

What are you doing?

I't trying to delete some records from a table

// My model definition
class MyModel extends Model {}
MyModel.init({
  userEmail: {
    type: DataTypes.STRING,
    field: 'user_email',
    primaryKey: true,
  },
  brandId: {
    type: DataTypes.INTEGER,
    field: 'brand_id',
    primaryKey: true,
  },
  description: {
    type: DataTypes.TEXT,
    allowNull: true,
  },
}, {
  sequelize,
  modelName: 'myModel',
  tableName: 'my_table',
  underscored: true,
  timestamps: false,
  version: false,
});

// How I used to run the query before v5
MyModel.destroy({ transaction, where: { userEmail:  'some email'} });

What do you expect to happen?

get this query:
DELETE FROM my_table WHERE "user_email"='some email'

What is actually happening?

I'm getting this other one:
DELETE FROM my_table WHERE "userEmail"='some email' producing column "userEmail" does not exist at character X

Environment

Dialect:

  • mysql
  • postgres
  • sqlite
  • mssql
  • any
    Dialect library version: 7.8.0
    Database version: 11.2
    Sequelize version: tested with v5.8.12 and v6.0.0
    Node Version: 10
    OS: macOS

Tested with latest release:

  • No
  • Yes, specify that version: 5.8.12 and 6.0.0

Activity

  1. papb commented on Jul 25, 2019

    @papb
    Member

    Closing in favor of #11225.

    When #11225 gets closed, if anyone thinks this particular issue is still an issue, please ping me.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions