[Pg-kit]: Fix invalid nextval default rendering in pg introspection#5416
Open
jimyungkoh wants to merge 1 commit intodrizzle-team:mainfrom
Open
[Pg-kit]: Fix invalid nextval default rendering in pg introspection#5416jimyungkoh wants to merge 1 commit intodrizzle-team:mainfrom
jimyungkoh wants to merge 1 commit intodrizzle-team:mainfrom
Conversation
The pg introspection flow could emit sequence-based numeric defaults as `.default(nextval(...))`, which generates invalid TypeScript in pulled schema files (issue drizzle-team#5413). This change normalizes pg serializer internals to schema-qualified table keys, makes introspect default metadata lookup schema-aware, and forces `nextval(...)` / `pg_catalog.nextval(...)` numeric defaults to render as SQL expressions. Also adds regression tests for: - non-public schema sequence defaults - pg_catalog.nextval defaults - duplicate table names across schemas Validation: - `pnpm --filter drizzle-kit exec vitest tests/introspect/pg.test.ts` passed (`38 passed | 1 skipped`) - `pnpm --filter drizzle-kit exec vitest tests/introspect` failed only due environment issues (missing better-sqlite3 native binding, no docker socket)
25cf3af to
a52fc21
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes invalid TypeScript generation for Postgres sequence-based numeric defaults during introspection.
Closes #5413
Root Cause
Default-expression metadata could be missed in schema-sensitive cases due to internals key mismatch and non-schema-aware lookup paths. When missed,
nextval(...)could be emitted withoutsql\`` wrapping.Changes
schema.tablein pg serializer.introspect-pg.nextval(...)andpg_catalog.nextval(...)defaults to expression rendering.name + schema) in view column mapping path.pg_catalog.nextval(...)Validation
pnpm --filter drizzle-kit exec vitest tests/introspect/pg.test.ts38 passed | 1 skippedpnpm --filter drizzle-kit exec vitest tests/introspectbetter-sqlite3)