Skip to content

feat: add SERIAL, BIGSERIAL, UUID, and TIMESTAMP WITH TIME ZONE columns - #17

Merged
omer-cengel merged 2 commits into
masterfrom
feature/postgresql-scalar-column-types
Sep 19, 2026
Merged

omer-cengel merged 2 commits into
masterfrom
feature/postgresql-scalar-column-types

Conversation

@omer-cengel

Copy link
Copy Markdown
Member

Summary

Schema snapshots can now declare SERIAL, BIGSERIAL, UUID, and
TIMESTAMP WITH TIME ZONE columns, and queries over them generate compiling,
type-safe Java. Previously these spellings failed as unsupported column types,
and TIMESTAMP(n) WITH TIME ZONE was silently reduced to TIMESTAMP because
the schema parser truncated a declared type at its first parenthesis.

Changes

  • Canonicalize a declared SQL type by upper-casing it, removing its
    parenthesized arguments, and collapsing whitespace, so
    TIMESTAMP WITH TIME ZONE resolves with or without a precision.
  • Accept SERIAL and BIGSERIAL as the delivered integer and bigint mappings,
    and model such a column as not nullable, because PostgreSQL defines them as
    those types with a sequence default and NOT NULL.
  • Map UUID to java.util.UUID and TIMESTAMP WITH TIME ZONE to
    java.time.OffsetDateTime in generated method parameters, result record
    components, and imports.
  • Reserve UUID and OffsetDateTime as generated type names so a query named
    after one of them cannot collide with the import it needs.
  • Cover the new types with schema-parser and generator tests, generated-source
    compilation, and PostgreSQL round-trip tests including null binding and null
    result reading for the nullable uuid and timestamptz columns.

Scope and non-goals

  • Only those four spellings are accepted, case-insensitively, plus an optional
    precision on TIMESTAMP WITH TIME ZONE. TIMESTAMPTZ, SERIAL4, SERIAL8,
    SMALLSERIAL, and TIMESTAMP WITHOUT TIME ZONE continue to fail as
    unsupported, so one spelling can never resolve to two mappings.
  • No other CREATE TABLE form is added: column defaults, references, and check
    constraints are unchanged.
  • Generated APIs keep using reference types; no Optional or nullable wrapper
    is introduced, and the JDBC runtime is unchanged.

Canonicalize a declared SQL type by removing its parenthesized arguments so
TIMESTAMP WITH TIME ZONE resolves with or without a precision, in any letter
case. SERIAL and BIGSERIAL reuse the integer and bigint mappings and are
modeled not nullable, UUID maps to java.util.UUID, and TIMESTAMP WITH TIME
ZONE maps to java.time.OffsetDateTime in generated parameters, result
components, and imports. Both simple type names are reserved so a query name
cannot collide with a generated import. No other type or alias spelling is
accepted.
Extend the PostgreSQL schema snapshot with serial, bigserial, uuid, and
timestamptz columns, write and read every value through generated methods, and
assert that null binds and reads back as null for the nullable columns. The
timestamptz value is compared by instant because PostgreSQL normalizes it to
the session time zone.
@omer-cengel
omer-cengel merged commit fdb07c3 into master Sep 19, 2026
6 checks passed
@omer-cengel
omer-cengel deleted the feature/postgresql-scalar-column-types branch September 19, 2026 20:12
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