drizzle-team / drizzle-team/drizzle-orm
[BUG]: drizzle-kit pull: schema and relations disagree on camelCase for acronym columns (CallID → callId vs callID)
- 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
**What is the undesired behavior?**
With default `introspect.casing: "camel"`, `drizzle-kit pull` on SQLite generates schema column keys and relation column refs with **different** camelCase algorithms for names ending in acronyms like `ID`.
Example DB column `CallID`:
```ts
// schema.ts (generated)
callId: text("CallID").primaryKey(),
// relations.ts (generated)
from: r.subset.callID, // ❌
to: r.callLog.callID, // ❌
```
TypeScript then fails with:
```
Property 'callID' does not exist on type '...'. Did you mean 'callId'? (2551)
```
**Root cause (in published kit)**
In the SQLite schema printer vs shared relations printer:
- schema keys: `escapeColumnKey(value.camelCase())` → npm `camelcase` (`preserveConsecutiveUppercase: false`) → `CallID` → `callId`
- relations (`pull-common`): `toCamelCase(value)` from `drizzle-orm/casing` → `CallID` → `callID`
Same package, two converters. Related prior reports / fix attempt:
- https://github.com/drizzle-team/drizzle-orm/issues/4497
- https://github.com/drizzle-team/drizzle-orm/pull/4498
Those track replacing npm `camelcase` with `toCamelCase`. This issue is the concrete **schema ↔ relations mismatch** symptom; still reproducible on `1.0.0-rc.4`.
Note: in the same `1.0.0-rc.4` build, the postgres payload path appears to use `toCamelCase` for schema keys as well, so the mismatch is especially visible on **SQLite pull**.
**What are the steps to reproduce it?**
1. Create a SQLite DB with:
```sql
CREATE TABLE "CallLog" ("CallID" TEXT PRIMARY KEY);
CREATE TABLE "Subset" (
"CallID" TEXT PRIMARY KEY REFERENCES "CallLog"("CallID")
);
```
2. Pull with default camel introspect casing:
```bash
drizzle-kit pull --dialect sqlite --url file:./test.db --out ./drizzle
```
3. Compare generated `schema.ts` vs `relations.ts` — `callId` vs `callID`.
4. Run `tsc` / open in the IDE: error 2551 on the relation `from`/`to` refs.
**What is the desired result?**
Schema object keys and relation `from`/`to` paths must use the **same** casing function (preferably one shared helper, e.g. `drizzle-orm`'s `toCamelCase`).
**Environment**
- Database engine: SQLite (local file)
- Specific to SQLite pull / schema printer path (postgres path in the same kit build looks consistent)
- Failure mode: generated TypeScript does not typecheck
- Suggested fix: unify on `toCamelCase` from `drizzle-orm` in the sqlite schema printer (same direction as #4498), or derive relation column identifiers from the already-cased schema field names
Contributor guide
Assessment
This issue has not been assessed yet.