drizzle-team / drizzle-team/drizzle-orm-docs
Docs are misleading for `casing`
- Dominant language
- MDX
- Stars
- 241
- Forks
- 401
- Avg merge
- 5h 44m
- Merged PRs (30d)
- 1
Description
When the `casing` parameter is described [in the docs](https://orm.drizzle.team/docs/sql-schema-declaration#camel-and-snake-casing), we see this example:
```ts
// 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:
```ts
export default defineConfig({
// ...
casing: 'snake_case'
});
```
But, as far as I can tell, this is [undocumented](https://orm.drizzle.team/docs/drizzle-config-file).
---
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.