Skip to content

feat(schema): accept table-level foreign key and check constraints - #18

Merged
omer-cengel merged 2 commits into
masterfrom
feature/postgresql-table-level-constraint-parsing
Sep 19, 2026
Merged

omer-cengel merged 2 commits into
masterfrom
feature/postgresql-table-level-constraint-parsing

Conversation

@omer-cengel

Copy link
Copy Markdown
Member

Summary

An ordinary PostgreSQL schema snapshot no longer has to be rewritten before sqlcj can read it. Table-level FOREIGN KEY and CHECK constraints, named or unnamed, are now accepted and ignored, because they carry no information that affects the generated Java types. Previously a foreign key was rejected as an unsupported table constraint and a check constraint failed with an unfocused error.

Changes

  • Accept and ignore table-level FOREIGN KEY (...) REFERENCES ... and CHECK (...), both unnamed and written as CONSTRAINT name ....
  • Keep parsed columns and recorded constraints unchanged: columns retain their name, type, and nullability, and only primary-key and unique constraints are recorded, in their declared order.
  • Report a table constraint that carries no constraint-type text as an unsupported table constraint instead of failing with a NullPointerException.
  • Add schema-parser tests covering column defaults (literal and function), column-level REFERENCES with and without a referential action, column-level CHECK, named table-level primary key and unique constraints, and clear rejection of a non-CREATE TABLE statement.
  • Add a PostgreSQL test that runs such a snapshot as real DDL, compiles the generated sources, and reads back the values the database defaults produced.

Scope and non-goals

Schema parsing only. The semantic schema model is unchanged: no new constraint kind is introduced, and generated Java APIs and the runtime are untouched. ALTER TABLE, views, materialized views, sequences as modeled objects, identity columns, EXCLUDE, new SQL types, and new query shapes remain unsupported, and a non-CREATE TABLE schema statement still fails clearly.

@omer-cengel
omer-cengel merged commit 104edf2 into master Sep 19, 2026
6 checks passed
@omer-cengel
omer-cengel deleted the feature/postgresql-table-level-constraint-parsing branch September 19, 2026 21:13
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.

1 participant