test(drivers): remove redundant object: key from mongodb/sql query test literals - #7579
Merged
Merged
Conversation
…terals
The 12 remaining call sites of the shape driver.find(table, { object: table, ... } as any)
in driver test files restated the object name inside the query literal even
though it is already the method's first argument. DriverQuery = Omit<QueryAST,
'object'> has no such key, and no driver source reads query.object (verified
zero hits under packages/drivers/*/src), so the key was inert duplication that
existed only to justify a blanket cast — which also switched off type checking
of where/orderBy/fields in the same literal, in conformance tests whose whole
job is pinning dialect behaviour.
At each site the object: key was deleted first, then the cast was dropped
where the remaining literal type-checks on its own; a cast was kept only where
the literal genuinely carries off-contract input (a where: unknown parameter,
or a Record<string, unknown> fixture spread) — verified by deliberately
breaking the literal and confirming tsc goes red, then restoring it.
Follow-up to #6231, which fixed the five source-only sites of the same shape.
Fixes #7177
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckNo hand-written docs reference the 0 changed package(s). ✅ |
This PR's sweep removed 7 object:-key erasure sites counted by the query-options-erasure test-surface aggregate, dropping it 249 -> 242. Per the ratchet's own instruction (scripts/check-query-options-erasure-ratchet.mjs), a count that falls must be ratcheted down in the same PR — a ceiling left above reality silently licenses that many new erasures. Ran `pnpm check:query-options-erasure --update` and verified the diff touches only testSurface.sites (249 -> 242), nothing else moved.
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.
Fixes #7177
What
12 call sites in driver test files restated the object name inside the query
literal (
{ object: table, ... } as any) even though it is already themethod's first argument — the same shape #6231 fixed in source files. At each
site the
object:key is deleted, and theas any/as nevercast isdropped wherever the remaining literal type-checks on its own without it.
query.objecthas zero readers inpackages/drivers/*/src(positive control:\.object\binsql-driver.tshits, so the zero is real) — no runtimebehavior changes.
Per-site list
mongodb-findone-options.test.ts{ object: 'account', ...c.query } as any{ ...c.query } as anymongodb-findone-options.test.ts{ object: 'account', where: { id: 'a' }, limit: 1 } as any{ where: { id: 'a' }, limit: 1 }mongodb-findone-options.test.ts{ object: 'account', where: { id: 'a' }, limit: 1 } as any(continuation line){ where: { id: 'a' }, limit: 1 }mongodb-findone-options.test.ts{ object: 'account', ...c.query } as any{ ...c.query } as anymongodb-findone-options.test.ts{ object: 'account', limit: 2, offset: 0 } as any{ limit: 2, offset: 0 }mongodb-findone-options.test.ts{ object: 'account' } as any{}mongodb-filter-logic-conformance.test.ts{ object: 'conformance', where: c.filter } as any{ where: c.filter }mongodb-filter-logic-conformance.test.ts{ object: 'conformance' } as any{}mongodb-findone-query.test.ts{ object: 'account', ...c.query } as any{ ...c.query } as anymongodb-findone-query.test.ts{ object: 'account', limit: 2, offset } as any{ limit: 2, offset }mongodb-filter-boolean-identity.test.ts{ object: 'deal', where } as never{ where } as neversql-driver-temporal-conformance.test.ts{ object: table, where } as any{ where } as any(Line numbers as re-verified on
origin/main@f7a60d9, matching the PM's12-site assumption in issue comment
5249416658, including the continuation-line site at
:144that a plain per-line grep misses.)Casts kept, and why
Per the fix shape's guidance (comment
5248086029), a cast survives onlywhere the literal's SUBJECT is genuinely off-contract input, verified by
deliberately breaking the literal (adding a bogus key / feeding it the wrong
type) and confirming
tscgoes red:{ ...c.query } as any(3 sites,mongodb-findone-options.test.tsandmongodb-findone-query.test.ts) —c.query: Record< string, unknown >, afixture table whose whole point is exercising arbitrary query shapes
(
FINDONE_CASES). Spreading aRecord< string, unknown >loses field-leveltyping structurally; the cast is load-bearing for the fixture's own design,
not for
object.{ where } as never(mongodb-filter-boolean-identity.test.ts:349) and{ where } as any(sql-driver-temporal-conformance.test.ts:118) — bothtake
where: unknownas a parameter (deliberately, to probefilter-translation edge cases). Confirmed: removing the cast and typechecking
the file directly (see Tests) gives
TS2322: Type 'unknown' is not assignable to type 'FilterCondition | undefined'.Everywhere else the cast is gone entirely — those literals type-check as
plain
DriverQueryobject literals onceobject:is removed.Landmines verified untouched
packages/objectql/src/engine-unknown-option.test.ts:183— the deliberatelyUNEQUAL
{ object: 'person' }rejection test (engine.find('task', { object: 'person' } as any)) — not a site, untouched.objectinsideexpandentries (same file,:191/:198) — names therelated object, not a site, untouched.
syncSchemasBatch([{ object, schema }])calls in the edited files.Closure
returns zero non-CHANGELOG hits.
Tests
pnpm --filter @objectstack/driver-mongodb typecheck— clean. Caveat:this package's
tsconfig.jsonexcludes**/*.test.ts, so this commandnever actually typechecks the edited files. Verified separately with an
ad-hoc tsconfig that includes tests (
extendsthe real one, drops the.test.tsexclusion) — introduces zero new errors versus the pre-existingbaseline (unrelated
NodeNexttop-level-await /Array.at()lib-mismatchnoise present on
origin/mainalready, nothing on any line this PRtouches). Used the same ad-hoc config to reverse-verify the two kept casts
above (bogus key /
where: unknown→ realtscerrors, then reverted).pnpm --filter @objectstack/driver-sql typecheck— clean (this package'stsconfig does include test files, so this one is a direct, unqualified
green).
pnpm --filter @objectstack/driver-mongodb test— 269 passed, 143 skipped(5 files requiring a real
mongod, gated byOS_TEST_MONGODB_MEMORY_SERVER_ENABLED,proxy blocks the binary per dispatch instructions).
pnpm --filter @objectstack/driver-sql test— 1296 passed, 48 skipped(env-gated live dialects).
node scripts/check-nul-bytes.mjs— OK.Tests-only change — no changeset;
skip-changesetlabel to be applied.Generated by Claude Code