Skip to content

Expand PostgreSQL CREATE TABLE LIKE imports - #1117

Open
yzxcj797 wants to merge 1 commit into
drawdb-io:mainfrom
yzxcj797:fix/471-postgres-create-table-like
Open

Expand PostgreSQL CREATE TABLE LIKE imports#1117
yzxcj797 wants to merge 1 commit into
drawdb-io:mainfrom
yzxcj797:fix/471-postgres-create-table-like

Conversation

@yzxcj797

Copy link
Copy Markdown

Summary

PostgreSQL CREATE TABLE ... (LIKE ...) statements are valid, but the SQL parser used by diagram import does not understand them. This adds a PostgreSQL-specific preprocessing pass before parsing:

  • split statements while respecting strings, comments, and dollar-quoted bodies;
  • remember the definition body of each preceding CREATE TABLE;
  • expand a LIKE <known table> clause into that table's definition text;
  • preserve any additional columns declared after the LIKE clause;
  • support chained copies (A LIKE B, then C LIKE A);
  • preserve quoted and schema-qualified identifiers;
  • leave unresolved LIKE sources unchanged rather than guessing a definition.

The expansion runs only for PostgreSQL imports and does not alter source for other databases.

Testing

  • npm test — 4/4 tests pass
    • basic LIKE ... INCLUDING ALL
    • extra columns and chained copies
    • quoted identifiers plus semicolons in defaults
    • unresolved source left unchanged
  • npm run lint — passes with zero warnings
  • npm run build — passes (existing lottie-web eval and large-chunk warnings remain)
  • npx prettier --check on the new files and package manifest — passes
  • git diff --check — passes

Fixes #471.

Expand LIKE clauses from earlier table definitions before SQL parsing, preserving extra columns, quoted identifiers, and statement text that the parser already supports. Unresolved sources are left unchanged rather than guessed.
@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

@yzxcj797 is attempting to deploy a commit to the dottle's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Support PostgreSQL "CREATE TABLE LIKE"

1 participant