Repository navigation
A filter object that mixes an in list, a not-null test or a range fails instead of dropping a condition - #2311
Merged
Conversation
…ls instead of dropping a condition
With `in` present, every other key of the operator object was ignored:
`{ in, not: null }` compiled and ran as the list alone, and `delete`
with a key beside `in` from untyped input removed the whole list. A
conditional upsert ignored a range beside `{ excluded }`.
The shared predicate now fails with the SchemaError other invalid
filters use, and each operator shape rules out the keys of the others
at the type level. The shapes moved to filterOperators.ts to keep
repositoryFilter.ts under the line limit.
`{ in, not: null }` compiled and returned the right rows before, so the
changeset is minor with a Breaking entry.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VjCSiB3Dk7BRBmjic6wFM5
marvin-bitterlich
enabled auto-merge
November 18, 2026 16:13
Coverage 92.0% (±0.0 pts) · Patch 100.0%All 7 added lines are covered.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why?
A repository filter object that mixes operators was not always refused. With an
inlist present, every other key in the object was dropped without a word:{ note: { in: ["paid"], not: null } }SchemaErrordelete({ id: { in: [1, 2], gt: 1 } })from a variable or untyped inputSchemaError, removes nothing{ value: { gt: 1, in: [1, 2] } }SchemaErrorSchemaError{ note: { like: "p%", not: null } }SchemaErrorSchemaErrorupdateWhere: { updatedAt: { excluded: "updatedAt", gte: since } }SchemaErrorThe
deleterow is the one that can hurt: the caller asked for less than was removed.How?
At run time, the shared predicate in
repositoryFilter.tsrefuses a key besideinwith the sameSchemaError(an unexpected key atfield.key) that the range branch already used. A reference to the incoming row,{ excluded: "field" }, is now a reference only when it is the object's one key, so a range beside it reaches the existing refusal.findMany,findOne,count,select,aggregate,delete,deleteBatched,latestPerGroupandupdateWhereall build theirwherefrom this predicate.At the type level, each operator shape now rules out the keys of the others: a list takes nothing beside
in,{ not: null }takes nothing besidenot, and ranges with a pattern take neitherinnornot. Inference is unchanged;repositoryFilter.typecheck.test.tsstill checks the result types of the same calls. The shapes moved tofilterOperators.tsbecauserepositoryFilter.tswent over the 150-line limit.Combinations that worked stay as they were: several ranges with a pattern in one object, and a JSON field whose schema accepts the object, which still compares it as a value.
Stories run against real PostgreSQL:
postgresMixedOperators.spec.tsforfindMany, the preparedselect,aggregateanddelete(which also reads back that no row was removed), and one more inpostgresConditionalUpsert.spec.ts. Each new story fails on main except "an in list beside a range" on reads, which main already refused and which is there as a guard. The typecheck cases are inrepositoryFilter.typecheck.test.tsandconditionalUpsert.typecheck.test.ts; on main every one of them compiled.Decisions
### Breakingentry, not a patch.{ in: [...], not: null }on a nullable field compiled and returned the right rows, because a list match already leaves out null. It now fails to compile and fails at run time. The migration is to removenot: null. Everything else that stops compiling failed at run time before or dropped a condition.inis refused whatever it is, including a key with anundefinedvalue and a key that names no operator.{ not: null }already counted keys this way.{ excluded, ... }in a conditional upsert'supdateWhereis included at run time only. It is the same predicate and the same silent drop. Its types still accept the mix: closing that would put anexcluded?: neverkey on the read filter shapes, which have no such concept.Callouts
Comparisonsis an exported type and now carriesin?: neverandnot?: never. A consumer that builds on it for its own operator objects gets the stricter shape.filterOperators.tsis reachable as@shivaedev/sql/filterOperators.tslike every source file of the package. It holds types only.deleteBatchedandlatestPerGroupshare the predicate and the types but have no story of their own for a mixed object.Generated by Claude Code