Skip to content

feat(schema): accept PostgreSQL spellings of supported column types - #42

Merged
omer-cengel merged 2 commits into
masterfrom
feature/postgresql-type-spellings
Sep 27, 2026
Merged

omer-cengel merged 2 commits into
masterfrom
feature/postgresql-type-spellings

Conversation

@omer-cengel

Copy link
Copy Markdown
Member

Summary

Schemas written for PostgreSQL often use the type names PostgreSQL itself documents, such as TIMESTAMPTZ, INT8, SERIAL8, or CHARACTER VARYING(20). sqlcj previously rejected these with Unsupported SQL column type. They now map to the same Java types as the spellings sqlcj already accepted, so an existing PostgreSQL schema no longer has to be rewritten for code generation.

Changes

  • INT4 and SERIAL4 map to Integer; INT8 and SERIAL8 map to Long; INT2, SMALLSERIAL, and SERIAL2 map to Short.
  • CHARACTER VARYING, CHAR, and CHARACTER map to String. PostgreSQL blank-pads CHAR(n) values, so ab stored in CHAR(3) reads back as ab .
  • TIMESTAMP WITHOUT TIME ZONE maps to java.time.LocalDateTime and TIMESTAMPTZ to java.time.OffsetDateTime.
  • Every serial spelling (SMALLSERIAL, SERIAL, BIGSERIAL, SERIAL2, SERIAL4, SERIAL8) is modeled as non-null. The integer aliases take their nullability from NOT NULL only.
  • Matching stays case-insensitive and ignores type arguments, as before, and the rejection message for unsupported types is unchanged.
  • Schema-parser tests cover each spelling, and a PostgreSQL integration test round trips a table declared entirely through these spellings via generated code.
  • The PostgreSQL documentation lists the accepted spellings and no longer lists them as rejected.

Scope and non-goals

  • Grammar-only synonyms (CHAR VARYING, DEC, NCHAR, BPCHAR), quoted or schema-qualified type names, the distinct "char" type, and array types remain unsupported.
  • No new Java types, analyzer, generator, or runtime changes.

@omer-cengel
omer-cengel merged commit 5d2674e into master Sep 27, 2026
6 checks passed
@omer-cengel
omer-cengel deleted the feature/postgresql-type-spellings branch September 27, 2026 12:27
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