Skip to content

Commit a2f71b6

Browse files
committed
fix tests
1 parent 59299b1 commit a2f71b6

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/drivers/bun-sql.codegen.test.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ describe("postgres driver codegen", () => {
196196
expect(output).toContain('import type { Sql as SQL } from "postgres"');
197197
});
198198

199-
it("produces same function signatures as bun-sql driver", () => {
200-
const bunDriver = new BunSqlDriver();
199+
it("generates simpler code that casts directly to Row type", () => {
201200
const postgresDriver = new PostgresDriver();
202201

203202
const params: Parameter[] = [
@@ -209,10 +208,7 @@ describe("postgres driver codegen", () => {
209208
{ name: "name", type: { name: "text" }, notNull: true } as unknown as Column,
210209
];
211210

212-
const bunOutput = print(
213-
bunDriver.oneDecl("getThing", "getThingQuery", "GetThingArgs", "GetThingRow", params, columns),
214-
);
215-
const postgresOutput = print(
211+
const output = print(
216212
postgresDriver.oneDecl(
217213
"getThing",
218214
"getThingQuery",
@@ -223,7 +219,9 @@ describe("postgres driver codegen", () => {
223219
),
224220
);
225221

226-
// The function bodies should be identical (both use SQL as the type name)
227-
expect(bunOutput).toBe(postgresOutput);
222+
// postgres.js driver casts directly to Row[] without .values()
223+
expect(output).toContain("as GetThingRow[]");
224+
expect(output).not.toContain(".values()");
225+
expect(output).toContain("rows[0] ?? null");
228226
});
229227
});

src/drivers/postgres-common.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,11 @@ export class PostgresCommonDriver {
424424
return [
425425
factory.createImportDeclaration(
426426
undefined,
427-
factory.createImportClause(useTypeImport, undefined, factory.createNamedImports([importSpecifier])),
427+
factory.createImportClause(
428+
useTypeImport,
429+
undefined,
430+
factory.createNamedImports([importSpecifier]),
431+
),
428432
factory.createStringLiteral(importModule),
429433
undefined,
430434
),

0 commit comments

Comments
 (0)