fix: use word-boundary regex for REFERENCES detection in query generators#18235
fix: use word-boundary regex for REFERENCES detection in query generators#18235Zelys-DFKH wants to merge 1 commit intosequelize:mainsequelize/sequelize:mainfrom Zelys-DFKH:fix/enum-references-false-positiveZelys-DFKH/sequelize:fix/enum-references-false-positiveCopy head branch name to clipboard
Conversation
…tors
DataTypes.ENUM('PREFERENCES') passes .includes('REFERENCES') in
createTableQuery and changeColumnQuery because "PREFERENCES" contains
"REFERENCES" as a substring. The ENUM column is then emitted as a
spurious FOREIGN KEY constraint instead of a column definition.
Replacing .includes('REFERENCES') with /\bREFERENCES\b/.test() across
all dialect query generators (mysql, mariadb, postgres, mssql,
snowflake, ibmi, oracle, db2).
Fixes sequelize#17544
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (13)
📝 WalkthroughWalkthroughThis PR fixes a bug where ENUM column types containing the word "PREFERENCES" (or other substrings with "REFERENCES") were incorrectly parsed as foreign key constraints. The fix replaces substring matching ( ChangesREFERENCES Keyword Detection Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Biome (2.4.16)packages/db2/src/query-generator.jsFile contains syntax errors that prevent linting: Line 3: Illegal use of an import declaration outside of a module; Line 4: Illegal use of an import declaration outside of a module; Line 8: Illegal use of an import declaration outside of a module; Line 12: Illegal use of an import declaration outside of a module; Line 13: Illegal use of an import declaration outside of a module; Line 14: Illegal use of an import declaration outside of a module; Line 15: Illegal use of an import declaration outside of a module; Line 16: Illegal use of an import declaration outside of a module; Line 17: Illegal use of an import declaration outside of a module; Line 18: Illegal use of an import declaration outside of a module; Line 19: Illegal use of an import declaration outside of a module; Line 20: Illegal use of an import declaration outside of a module; Line 21: Illegal use of an import declaration outside of a module; Line 22: Illegal use of an import declaration outside of a module; Line 23: Illegal use of an import declaration outside of a module; Line 24: Illegal use of an import declaration outside of a module; Line 25: Illegal use of an import declaration outside of a module; Line 26: Illegal use of an import declaration outside of a module; Line 27: Illegal use of an import declaration outside of a module; Line 28: Illegal use of an import declaration outside of a module; Line 37: Illegal use of an export declaration outside of a module packages/ibmi/src/query-generator.jsFile contains syntax errors that prevent linting: Line 3: Illegal use of an import declaration outside of a module; Line 4: Illegal use of an import declaration outside of a module; Line 8: Illegal use of an import declaration outside of a module; Line 12: Illegal use of an import declaration outside of a module; Line 13: Illegal use of an import declaration outside of a module; Line 14: Illegal use of an import declaration outside of a module; Line 15: Illegal use of an import declaration outside of a module; Line 16: Illegal use of an import declaration outside of a module; Line 17: Illegal use of an import declaration outside of a module; Line 21: Illegal use of an import declaration outside of a module; Line 22: Illegal use of an import declaration outside of a module; Line 23: Illegal use of an import declaration outside of a module; Line 24: Illegal use of an import declaration outside of a module; Line 25: Illegal use of an import declaration outside of a module; Line 31: Illegal use of an export declaration outside of a module packages/mariadb/src/query-generator.jsFile contains syntax errors that prevent linting: Line 3: Illegal use of an import declaration outside of a module; Line 7: Illegal use of an import declaration outside of a module; Line 8: Illegal use of an import declaration outside of a module; Line 9: Illegal use of an import declaration outside of a module; Line 10: Illegal use of an import declaration outside of a module; Line 11: Illegal use of an import declaration outside of a module; Line 15: Illegal use of an export declaration outside of a module
🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
DataTypes.ENUM('PREFERENCES')passes the.includes('REFERENCES')check increateTableQueryandchangeColumnQuerybecause "PREFERENCES" contains "REFERENCES" as a substring. This causes the ENUM column to be emitted as a spuriousFOREIGN KEY ... REFERENCESconstraint instead of a column definition.Replacing
.includes('REFERENCES')with/\bREFERENCES\b/.test(...)fixes this across all eight dialect query generators (mysql, mariadb, postgres, mssql, snowflake, ibmi, oracle, db2). The db2 dialect used lodash's_.includes, which is semantically equivalent on string inputs; replaced with the same regex for consistency.Fixes #17544
Summary by CodeRabbit
Bug Fixes
Tests