Repository navigation
fix(core): make empty Op.notIn compose correctly under Op.or and Op.not - #18250
Conversation
|
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 (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughEmpty ChangesEmpty Op.notIn always-true fix
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
SippieCup
left a comment
There was a problem hiding this comment.
Good catch.
Simple and well tested for any regressions. no changes needed.
|
@WikiRik this is good to merge. I did think about one random "bug" just now though. index generation might be broken if this ever happens on mssql/psql since they don't like no-column comparisons. But I can't see anyone really building that into a index where statement, maybe if some programmatic one was created? Anyway, I thought it should be noted and then just move on with life, and let the poor SOB who does have this happen have this comment here to tell them to fix their where statement. |
Co-authored-by: Rik Smale <[email protected]>
Pull Request Checklist
Description of Changes
Closes #18248
An empty
Op.notInarray is logically always true (NOT IN ()matches every row), and Sequelize special-cased it by emitting an empty string. An empty fragment is a safe identity only forAND: bothjoinWithLogicalOperator(which filters out empty fragments) andwrapWithNot(which returns''for empty input) silently drop it, changing the meaning of the query when it is composed:An empty
Op.notInnow emits1 = 1— an always-true condition valid in every supported dialect — mirroring how an emptyOp.inemits the always-falseIN (NULL).Added regression tests covering the emitted fragment itself and its composition under
Op.or,Op.notandOp.and.Note: a top-level
{ [Op.notIn]: [] }now generatesWHERE 1 = 1instead of omitting the WHERE clause entirely. This is semantically identical (all rows, preserving #4859 / #4860), but code asserting on the exact generated SQL will see a difference.Credit: root cause analysis and suggested approach by @tsushanth in #18248.
List of Breaking Changes
None.
Summary by CodeRabbit
Bug Fixes
NOT INfilters to emit a valid always-true predicate instead of being omitted from the query.NOT INappears insideAND,OR, andNOTcombinations.Tests
NOT IN.NOT INscenarios.