drizzle-team / drizzle-team/drizzle-orm

[BUG]: Wrong introspection of column name on drizzle-kit pull

Open
#4,497 0 comments 0 reactions 0 assignees View on GitHub
bug bug/fixed-in-beta
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?

0.43.1

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

0.31.1

### Other packages

_No response_

### Describe the Bug

## What is the undesired behavior?
When pulling the schema, I am getting the wrong column name.
I have a table with this DDL:
```sql
CREATE SCHEMA "my-schema";
--> statement-breakpoint
CREATE TABLE "my-schema"."test_table" (
"abc123def" numeric
);
```

Upon pulling using `drizzle-kit pull`, this is the schema that is generated:
```ts
export const mySchema = pgSchema("my-schema");
export const testTableInMySchema = mySchema.table("test_table", {
abc123Def: numeric(),
});
```
Since there's no name provided to `numeric()`, the camelcasing is messing up the column name.
I have looked into the code (`introspect-pg.ts`). It feels like the `String.prototype.camelCase` function in `drizzle-kit/src/@types/utils.ts` is responsible for this. Since we are using the _camelcase_ npm package 😭 (why???). We already have a `toCamelCase` in `drizzle-orm/src/casing.ts`, using which I am able to pass the tests as well in the `pg.test.ts` file.
I am raising a PR for the same.

## What are the steps to reproduce it?
Reproduction Repo: https://github.com/ssahillppatell/drizzle-orm-issue-repro

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.