Skip to content

DataType.ENUM("PREFERENCES") is parsed as "REFERENCES" so foreign key is tried to be generated. #17544

Description

@piotr-pawlowski

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

This migration generates wrong SQL query:

up: (queryInterface, Sequelize) => queryInterface.changeColumn('Operation', 'operation', {
    type: Sequelize.DataTypes.ENUM(
      'UPDATE_USER_PREFERENCES'
    ),
    allowNull: false
  }),

What is actually happening?

Sequelize generates query as below:

Executing (default): ALTER TABLE `Operation` ADD FOREIGN KEY (`operation`) REFERENCES') NOT NULL;

I guess that keyword PREFERENCES is parsed as REFERENCES so Sequelize tries to create a foreign key.

  • Sequelize version: 6.37.4
  • Node.js version: v18.12.1
  • If TypeScript related: TypeScript version: 4.7.4
  • Database & Version: MySQL 5.7

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 will need guidance.
  • No, I don't have the time, but my company or I are supporting Sequelize through donations on OpenCollective.
  • [X ] 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
    pending-approval
    type: bug
    on Oct 8, 2024
  2. removed
    pending-approval
    on Nov 16, 2024
  3. moved this to Check if fixed in v7 in Starting issueson Feb 12, 2025
  4. added theissue type on Mar 9, 2025
  5. removed
    type: bug
    on Mar 9, 2025
  6. added a commit that references this issue on Oct 26, 2026
    4d6f0e9
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

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions