Skip to content

Docs are misleading for casing #609

@nimonian

Description

@nimonian

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions