drizzle-team / drizzle-team/drizzle-orm
[BUG]: Inconsistency in PgView Casing
- 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.39.2
### What version of `drizzle-kit` are you using?
0.30.4
### Other packages
_No response_
### Describe the Bug
Defining a pgView as follows:
```TypeScript
export const test = pgTable('test', {
testId: serial().primaryKey(),
testName: text().notNull(),
});
export const testView = pgView('test_view').as((qb) => {
return qb
.select({
testId: test.testId,
testName: test.testName,
})
.from(test);
});
```
Results in the following migration file:
```SQL
CREATE TABLE "test" (
"test_id" serial PRIMARY KEY NOT NULL,
"test_name" text NOT NULL
);
--> statement-breakpoint
CREATE VIEW "public"."test_view" AS (select "testId", "testName" from "test");
```
Notice how the in `test` table names have been correctly converted to `snake_case` while the `CREATE VIEW` statement refers in `camelCase`.
This results in a broken migration.
I would expect testId and testName to be referenced as `test_id` and `test_name` in the view as well.
Contributor guide
Assessment
This issue has not been assessed yet.