drizzle-team / drizzle-team/drizzle-orm

[BUG]: snakeCase handling of numbers

Open
#6,037 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Report hasn't been filed before.

- [x] I have verified that the bug I'm about to report hasn't been filed before.

### What version of `drizzle-orm` are you using?

1.0.0-rc.4

### What version of `drizzle-kit` are you using?

1.0.0-rc.4

### Other packages

_No response_

### Describe the Bug

My this needs some discussion because there is no universal standard for number handling in snake_case. Treating numbers as word boundaries is just a common convention.

```ts
import { integer, text, snakeCase } from 'drizzle-orm/pg-core';

export const test = snakeCase.table('test', {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
thisIs1Test: text()
}
```
### Actual Behavior

The column name is converted to: this_is1_Test
### Expected Behavior

The column name should be converted to: this_is_1_test

### Workaround
```ts
import { integer, text, snakeCase } from 'drizzle-orm/pg-core';

export const test = snakeCase.table('test', {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
thisIs1Test: text('this_is_1_test')
}

Contributor guide

Open the contributing guide

Research direction

Start at the snakeCase entry point exposed by drizzle-orm/pg-core and inspect how the mixed letters and number in thisIs1Test are converted. Compare the generated name with this_is_1_test, then add focused coverage for the conversion and verify the regression.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, typescript
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.