Skip to content

docs: empty Op.or & Op.not now throw in v7 - #841

Draft
WikiRik wants to merge 1 commit into
mainfrom
docs/empty-op-or-not-throws
Draft

docs: empty Op.or & Op.not now throw in v7#841
WikiRik wants to merge 1 commit into
mainfrom
docs/empty-op-or-not-throws

Conversation

@WikiRik

@WikiRik WikiRik commented Jul 29, 2026

Copy link
Copy Markdown
Member

Documents sequelize/sequelize#18286. Draft — do not merge until that PR lands.

Why

The v7 upgrade guide has a section, ### Changes to empty OR & NOT operators, that documents the behaviour introduced by #15598: an empty Op.or or Op.not is completely ignored, so where: or([]) produces SELECT * FROM "users" with no condition.

#18286 reverses that. Both now throw, because ignoring the operator silently widens the query to every row — including for Model.update and Model.destroy, where it defeats the safeguard that refuses to run those methods without a where. Once #18286 lands, the current section documents behaviour that no longer exists.

What changed

  • Retitled to "Empty OR & NOT operators now throw", and attributed to both #15598 and #18286.
  • Kept the v6 → v7 history (0=1 → ignored → throws), naming the alpha window (7.0.0-alpha.24 through 7.0.0-alpha.48) in which the ignoring behaviour shipped, so readers upgrading between alphas can tell which one they are on.
  • Listed the forms that throw, including the attribute-level ({ firstName: { [Op.or]: [] } }) and nested ({ [Op.and]: [{ ... }, { [Op.or]: [] }] }) cases that #18286 also covers.
  • Added the two migration paths the error message itself suggests: sql`1 = 0` to match no rows, or omitting the operator to apply no condition.
  • Added the empty-list guard example, since building Op.or from a list that turned out empty is the common way to hit this.
  • Added an :::info note that Op.and is deliberately not affected — an empty conjunction is vacuously true, so { [Op.and]: [] } correctly stays "no condition". #18286 pins this with tests; the note is there so it does not get "fixed" for symmetry later.

Drive-by fix

The old example used not({}). There is no not() export in v7 — packages/core/src/sequelize.js exports and() and or() only. Replaced with or({}) and the Op.not object forms, which are real.

Checks

  • prettier --check docs/other-topics/upgrade.md clean (run with 3.5.3 rather than the pinned 3.8.2; CI covers the pinned version).
  • Docusaurus site not built locally — the change is prose plus fenced code blocks in an existing file, no new links or components beyond the :::info admonition already used elsewhere in this file.

Created by Opus 5 with Claude Code, supervised by @WikiRik.

Rewrites the "Changes to empty OR & NOT operators" section of the v7
upgrade guide to match sequelize/sequelize#18286, which makes an empty
Op.or or Op.not throw instead of compiling to no condition at all.

The section previously documented the alpha behaviour introduced by
sequelize/sequelize#15598 as final.

Also drops the stale `not({})` example: v7 exports `and()` and `or()`,
but there is no `not()` helper.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🚀 Website draft URL
📋 Deployment logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant