Skip to content

[BUG]: Inconsistency in PgView Casing #4181

@dancamdev

Description

@dancamdev

Report hasn't been filed before.

  • 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:

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions