Skip to content

Support implicit PostgreSQL foreign key references - #1101

Open
yzxcj797 wants to merge 1 commit into
drawdb-io:mainfrom
yzxcj797:fix/postgres-implicit-references-669
Open

Support implicit PostgreSQL foreign key references#1101
yzxcj797 wants to merge 1 commit into
drawdb-io:mainfrom
yzxcj797:fix/postgres-implicit-references-669

Conversation

@yzxcj797

Copy link
Copy Markdown

Fixes #669.

Summary

  • retry PostgreSQL CREATE TABLE imports that omit referenced columns using a narrowly scoped compatibility marker
  • resolve those references to the target table's declared primary key, including ordered composite keys
  • parse the original SQL first, preserve original parser errors if compatibility parsing also fails, and leave explicit references and other SQL dialects unchanged
  • add regression tests to the Node 20/22 build matrix

Scope and compatibility

This follows the importer's existing ordering and name-resolution behavior: the referenced table must appear earlier in the input, and this compatibility path handles unqualified table names. Explicit REFERENCES table(column) clauses are unchanged.

Testing

  • npm test - 3 passed
  • npm run lint
  • npm run build - passed (existing dependency eval and bundle-size warnings only)
  • npx prettier --check .github/workflows/build.yml package.json src/components/EditorHeader/Modal/Modal.jsx src/utils/importSQL/postgres.js src/utils/importSQL/postgresImplicitReferences.js test/postgres-implicit-references.test.js
  • git diff --check

AI assistance

OpenAI Codex assisted with diagnosis, implementation, tests, and review. I reviewed the final behavior and diff, ran the validation above, and take responsibility for the submitted change.

Resolve REFERENCES clauses without an explicit column list to the referenced table's primary key, including composite keys.

Fixes drawdb-io#669
@vercel

vercel Bot commented Aug 13, 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.

[BUG] Importing SQL (PostgreSQL) with Foreign Key reference does cause a SyntaxError

1 participant