Repository navigation
feat: add SERIAL, BIGSERIAL, UUID, and TIMESTAMP WITH TIME ZONE columns - #17
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Schema snapshots can now declare
SERIAL,BIGSERIAL,UUID, andTIMESTAMP WITH TIME ZONEcolumns, and queries over them generate compiling,type-safe Java. Previously these spellings failed as unsupported column types,
and
TIMESTAMP(n) WITH TIME ZONEwas silently reduced toTIMESTAMPbecausethe schema parser truncated a declared type at its first parenthesis.
Changes
parenthesized arguments, and collapsing whitespace, so
TIMESTAMP WITH TIME ZONEresolves with or without a precision.SERIALandBIGSERIALas 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.UUIDtojava.util.UUIDandTIMESTAMP WITH TIME ZONEtojava.time.OffsetDateTimein generated method parameters, result recordcomponents, and imports.
UUIDandOffsetDateTimeas generated type names so a query namedafter one of them cannot collide with the import it needs.
compilation, and PostgreSQL round-trip tests including null binding and null
result reading for the nullable
uuidandtimestamptzcolumns.Scope and non-goals
precision on
TIMESTAMP WITH TIME ZONE.TIMESTAMPTZ,SERIAL4,SERIAL8,SMALLSERIAL, andTIMESTAMP WITHOUT TIME ZONEcontinue to fail asunsupported, so one spelling can never resolve to two mappings.
CREATE TABLEform is added: column defaults, references, and checkconstraints are unchanged.
Optionalor nullable wrapperis introduced, and the JDBC runtime is unchanged.