-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
Environment
db0 commit: 1e7ea10
Node.js version: v22.20.0
Reproduction
// main.mts
import { drizzle } from "drizzle-orm/better-sqlite3";
import { integer, sqliteTable } from "drizzle-orm/sqlite-core";
import { eq } from "drizzle-orm";
const table = sqliteTable("mytable", {
fooBar: integer("foo_bar"),
});
const db = drizzle(":memory:", { schema: { table } });
await db.run("CREATE TABLE mytable (foo_bar INTEGER)");
await db.run("INSERT INTO mytable (foo_bar) VALUES (1)");
const result = await db.select().from(table).where(eq(table.fooBar, 1));
console.log(result);// main-db0.mts
import { createDatabase } from "db0";
import sqlite from "db0/connectors/better-sqlite3";
import { drizzle } from "db0/integrations/drizzle";
import { integer, sqliteTable } from "drizzle-orm/sqlite-core";
import { eq } from "drizzle-orm";
const table = sqliteTable("mytable", {
fooBar: integer("foo_bar"),
});
const db0 = createDatabase(sqlite({ name: ":memory:" }));
await db0.sql`CREATE TABLE mytable (foo_bar INTEGER)`;
await db0.sql`INSERT INTO mytable (foo_bar) VALUES (1)`;
const db = drizzle(db0, { schema: { table } });
const result = await db.select().from(table).where(eq(table.fooBar, 1));
console.log(result);Describe the bug
Drizzle converts the keys of rows returned from the database to match the typescript name, i.e. fooBar in this case. db0, however, does not and instead the result contains { foo_bar: 1 } which is in conflict with the infered type
const result: {
fooBar: number | null;
}[]Additional context
Used versions:
Logs
$ tsx main.mts
[ { fooBar: 1 } ]
$ tsx main-db0.mts
[ { foo_bar: 1 } ]Metadata
Metadata
Assignees
Labels
No labels