db0
db0 copied to clipboard
Drizzle integration select keys gets overridden by column names
Environment
node: v22.1.0 pnpm: 9.1.4 better-sqlite3: ^11.0.0 db0: ^0.1.4 drizzle-orm: ^0.31.0
Reproduction
https://github.com/Twitch0125/db0-drizzle-select-bug
Describe the bug
I first noticed this in a nuxt project but it seems to be happening using only db0.
when passing an object to select()
from the db0 drizzle integration it doesn't seem to honor the given keys, unlike using a drizzle instance directly.
import sqlite from "db0/connectors/better-sqlite3";
const db = createDatabase(sqlite())
const res = await db0DrizzleClient
.select({
name: table.name,
contact: table.ratings_contact, //we'd expect `ratings_contact` to be put on the `contact` key
power: table.ratings_power,
gap: table.ratings_gap,
})
.from(table);
//but res looks like this instead
/* [{
name: 'bob',
ratings_contact: 40, //uses the db column instead
ratings_power: 60,
ratings_gap: 40
}]
*/
Additional context
No response
Logs
No response