-
Notifications
You must be signed in to change notification settings - Fork 362
Description
When the casing parameter is described in the docs, we see this example:
// schema.ts
import { drizzle } from "drizzle-orm/node-postgres";
import { integer, pgTable, varchar } from "drizzle-orm/pg-core";
export const users = pgTable('users', {
id: integer(),
firstName: varchar()
})
// db.ts
const db = drizzle({ connection: process.env.DATABASE_URL, casing: 'snake_case' })
// query.ts
await db.select().from(users);However, this clearly won't work. The casing param is provided at runtime, and drizzle is not aware of any column aliasing settings during migration. As a minimum working example, this fails. The column is named firstName in the database.
Now, through some amount of experimentation, I discovered that I can provide a casing option to defineConfig like this:
export default defineConfig({
// ...
casing: 'snake_case'
});But, as far as I can tell, this is undocumented.
Proposal: if I'm correct in the above, I propose to properly document the casing option to defineConfig, and also make it clear that this option must be specified when discussing the casing in the schema declaration docs.
I am happy to make a PR, but I need someone more knowledgeable in Drizzle to confirm that what I've said is accurate.