Skip to content

test(drivers): remove redundant object: key from mongodb/sql query test literals - #7579

Merged
huangyiirene merged 2 commits into
mainfrom
claude/issue-7177-object-key-test-sweep
Aug 11, 2026
Merged

test(drivers): remove redundant object: key from mongodb/sql query test literals#7579
huangyiirene merged 2 commits into
mainfrom
claude/issue-7177-object-key-test-sweep

Conversation

@huangyiirene

@huangyiirene huangyiirene commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

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 the
method's first argument — the same shape #6231 fixed in source files. At each
site the object: key is deleted, and the as any / as never cast is
dropped wherever the remaining literal type-checks on its own without it.

query.object has zero readers in packages/drivers/*/src (positive control:
\.object\b in sql-driver.ts hits, so the zero is real) — no runtime
behavior changes.

Per-site list

File Line Before After
mongodb-findone-options.test.ts 117 { object: 'account', ...c.query } as any { ...c.query } as any
mongodb-findone-options.test.ts 136 { object: 'account', where: { id: 'a' }, limit: 1 } as any { where: { id: 'a' }, limit: 1 }
mongodb-findone-options.test.ts 144 { object: 'account', where: { id: 'a' }, limit: 1 } as any (continuation line) { where: { id: 'a' }, limit: 1 }
mongodb-findone-options.test.ts 154 { object: 'account', ...c.query } as any { ...c.query } as any
mongodb-findone-options.test.ts 163 { object: 'account', limit: 2, offset: 0 } as any { limit: 2, offset: 0 }
mongodb-findone-options.test.ts 168 { object: 'account' } as any {}
mongodb-filter-logic-conformance.test.ts 72 { object: 'conformance', where: c.filter } as any { where: c.filter }
mongodb-filter-logic-conformance.test.ts 85 { object: 'conformance' } as any {}
mongodb-findone-query.test.ts 61 { object: 'account', ...c.query } as any { ...c.query } as any
mongodb-findone-query.test.ts 70 { object: 'account', limit: 2, offset } as any { limit: 2, offset }
mongodb-filter-boolean-identity.test.ts 349 { object: 'deal', where } as never { where } as never
sql-driver-temporal-conformance.test.ts 118 { object: table, where } as any { where } as any

(Line numbers as re-verified on origin/main @ f7a60d9, matching the PM's
12-site assumption in issue comment 5249416658, including the continuation-
line site at :144 that a plain per-line grep misses.)

Casts kept, and why

Per the fix shape's guidance (comment 5248086029), a cast survives only
where 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 tsc goes red:

  • { ...c.query } as any (3 sites, mongodb-findone-options.test.ts and
    mongodb-findone-query.test.ts) — c.query: Record< string, unknown >, a
    fixture table whose whole point is exercising arbitrary query shapes
    (FINDONE_CASES). Spreading a Record< string, unknown > loses field-level
    typing 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) — both
    take where: unknown as a parameter (deliberately, to probe
    filter-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 DriverQuery object literals once object: is removed.

Landmines verified untouched

  • packages/objectql/src/engine-unknown-option.test.ts:183 — the deliberately
    UNEQUAL { object: 'person' } rejection test (engine.find('task', { object: 'person' } as any)) — not a site, untouched.
  • object inside expand entries (same file, :191/:198) — names the
    related object, not a site, untouched.
  • No syncSchemasBatch([{ object, schema }]) calls in the edited files.

Closure

git grep -nP "\.(find|findOne|count|updateMany|deleteMany|explain)\(\s*('[^']*'|\"[^\"]*\"|[A-Za-z_\$][\w.\$!]*)\s*,\s*\{\s*object:\s*\2\s*[,}]" -- packages apps

returns zero non-CHANGELOG hits.

Tests

  • pnpm --filter @objectstack/driver-mongodb typecheck — clean. Caveat:
    this package's tsconfig.json excludes **/*.test.ts, so this command
    never actually typechecks the edited files. Verified separately with an
    ad-hoc tsconfig that includes tests (extends the real one, drops the
    .test.ts exclusion) — introduces zero new errors versus the pre-existing
    baseline (unrelated NodeNext top-level-await / Array.at() lib-mismatch
    noise present on origin/main already, nothing on any line this PR
    touches). Used the same ad-hoc config to reverse-verify the two kept casts
    above (bogus key / where: unknown → real tsc errors, then reverted).
  • pnpm --filter @objectstack/driver-sql typecheck — clean (this package's
    tsconfig 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 by OS_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-changeset label to be applied.


Generated by Claude Code

…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
@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Aug 11, 2026 6:10am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

No 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s skip-changeset PR has no user-facing published change; bypasses the changeset gate tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[finding][drivers] The object-in-query sweep of #6231 was source-only — 10 more sites of the same shape live in driver test files

2 participants