Skip to content

Commit bd38c68

Browse files
committed
test(drivers): remove redundant object: key from mongodb/sql query literals
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
1 parent f7a60d9 commit bd38c68

5 files changed

Lines changed: 12 additions & 12 deletions

File tree

packages/drivers/driver-mongodb/src/mongodb-filter-boolean-identity.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ describe.skipIf(!sharedMongod)('[#5239] a real mongod returns the identity row s
346346
});
347347

348348
const ids = async (where: unknown): Promise<string[]> => {
349-
const rows = await driver.find('deal', { object: 'deal', where } as never);
349+
const rows = await driver.find('deal', { where } as never);
350350
return (rows as Record<string, unknown>[]).map((r) => String(r.id)).sort();
351351
};
352352

packages/drivers/driver-mongodb/src/mongodb-filter-logic-conformance.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe.skipIf(!sharedMongod)('driver-mongodb — filter logic conformance', ()
6969

7070
for (const c of FILTER_LOGIC_CASES) {
7171
it(c.name, async () => {
72-
const rows = await driver.find('conformance', { object: 'conformance', where: c.filter } as any);
72+
const rows = await driver.find('conformance', { where: c.filter });
7373
const got = (rows as any[])
7474
.map((r) => String(r.id))
7575
.sort((x, y) => x.localeCompare(y));
@@ -82,7 +82,7 @@ describe.skipIf(!sharedMongod)('driver-mongodb — filter logic conformance', ()
8282
* failed cannot read as a case that correctly excluded everything.
8383
*/
8484
it('the fixture really is all four rows', async () => {
85-
const rows = await driver.find('conformance', { object: 'conformance' } as any);
85+
const rows = await driver.find('conformance', {});
8686
expect((rows as any[]).map((r) => String(r.id)).sort()).toEqual(['1', '2', '3', '4']);
8787
});
8888
});

packages/drivers/driver-mongodb/src/mongodb-findone-options.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ describe('MongoDBDriver.findOne hands Mongo the whole query (#4419)', () => {
114114

115115
for (const c of FINDONE_CASES) {
116116
it(`emits the right options — ${c.name}`, async () => {
117-
await driver.findOne('account', { object: 'account', ...c.query } as any);
117+
await driver.findOne('account', { ...c.query } as any);
118118
const { options } = lastFindOne();
119119

120120
// `undefined` here is a real assertion, not an absent one: it is the
@@ -133,15 +133,15 @@ describe('MongoDBDriver.findOne hands Mongo the whole query (#4419)', () => {
133133
}
134134

135135
it('translates the predicate, as it always did', async () => {
136-
await driver.findOne('account', { object: 'account', where: { id: 'a' }, limit: 1 } as any);
136+
await driver.findOne('account', { where: { id: 'a' }, limit: 1 });
137137
expect(lastFindOne().filter).toMatchObject({ id: 'a' });
138138
});
139139

140140
it('the transaction session still rides through', async () => {
141141
const session = { id: 'sess-1' } as any;
142142
await driver.findOne(
143143
'account',
144-
{ object: 'account', where: { id: 'a' }, limit: 1 } as any,
144+
{ where: { id: 'a' }, limit: 1 },
145145
{ transaction: session } as any,
146146
);
147147
expect(lastFindOne().options.session).toBe(session);
@@ -151,7 +151,7 @@ describe('MongoDBDriver.findOne hands Mongo the whole query (#4419)', () => {
151151

152152
for (const c of FINDONE_CASES) {
153153
it(`selects the right row — ${c.name}`, async () => {
154-
const row = await driver.findOne('account', { object: 'account', ...c.query } as any);
154+
const row = await driver.findOne('account', { ...c.query } as any);
155155
expect(row === null ? null : String((row as any).id)).toBe(c.expectId);
156156
if (c.expectKeys && row) expect(new Set(Object.keys(row))).toEqual(new Set(c.expectKeys));
157157
});
@@ -160,12 +160,12 @@ describe('MongoDBDriver.findOne hands Mongo the whole query (#4419)', () => {
160160
// ── find() is unchanged: the carve-out is findOne-only ──────────────
161161

162162
it('an unordered PAGED find still gets a deterministic order imposed', async () => {
163-
await driver.find('account', { object: 'account', limit: 2, offset: 0 } as any);
163+
await driver.find('account', { limit: 2, offset: 0 });
164164
expect(seen.find.at(-1)!.options.sort).toEqual({ id: 1 });
165165
});
166166

167167
it('an unordered, unpaged find still gets none — that rule is unchanged', async () => {
168-
await driver.find('account', { object: 'account' } as any);
168+
await driver.find('account', {});
169169
expect(seen.find.at(-1)!.options.sort).toBeUndefined();
170170
});
171171
});

packages/drivers/driver-mongodb/src/mongodb-findone-query.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe.skipIf(!sharedMongod)('driver-mongodb — findOne executes the whole qu
5858

5959
for (const c of FINDONE_CASES) {
6060
it(c.name, async () => {
61-
const row = await driver.findOne('account', { object: 'account', ...c.query } as any);
61+
const row = await driver.findOne('account', { ...c.query } as any);
6262
expect(row === null ? null : String((row as any).id)).toBe(c.expectId);
6363
if (c.expectKeys && row) expect(new Set(Object.keys(row))).toEqual(new Set(c.expectKeys));
6464
});
@@ -67,7 +67,7 @@ describe.skipIf(!sharedMongod)('driver-mongodb — findOne executes the whole qu
6767
it('find() is unchanged — a paged walk is still a partition of the rows', async () => {
6868
const seen: string[] = [];
6969
for (let offset = 0; offset < FINDONE_ROWS.length; offset += 2) {
70-
const page = await driver.find('account', { object: 'account', limit: 2, offset } as any);
70+
const page = await driver.find('account', { limit: 2, offset });
7171
seen.push(...page.map((r) => String(r.id)));
7272
}
7373
expect(seen).toHaveLength(FINDONE_ROWS.length);

packages/drivers/driver-sql/src/sql-driver-temporal-conformance.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const timeShape = (name: string) => ({
115115

116116
/** Row ids a filter reaches, sorted — the one thing every cell must agree on. */
117117
async function matchedIds(driver: SqlDriver, table: string, where: unknown): Promise<string[]> {
118-
const rows = await driver.find(table, { object: table, where } as any);
118+
const rows = await driver.find(table, { where } as any);
119119
return (rows as any[]).map((r) => r.id).sort();
120120
}
121121

0 commit comments

Comments
 (0)