Skip to content

Commit

Permalink
Add HSQL support for generated clauses (#328)
Browse files Browse the repository at this point in the history
Both HSQLDB and H2 support both variants of this clause. See http://hsqldb.org/doc/2.0/guide/databaseobjects-chapt.html#dbc_tables and https://h2database.com/html/grammar.html#column_definition respectively.

Support for this was previously implemented for Postgres in 52c847 (#295).
  • Loading branch information
MariusVolkhart authored Feb 22, 2022
1 parent d746286 commit 4b3333e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ column_constraint ::= [ CONSTRAINT {identifier} ] (
NOT NULL {conflict_clause} |
UNIQUE {conflict_clause} |
{check_constraint} |
generated_clause |
{default_constraint} |
COLLATE {collation_name} |
{foreign_key_clause}
Expand Down Expand Up @@ -86,4 +87,6 @@ interval_qualifier ::= start_field TO end_field | single_datetime_field
start_field ::= non_second_primary_datetime_field [ '(' digit ')' ]
end_field ::= non_second_primary_datetime_field | 'SECOND' [ '(' digit ')' ]
single_datetime_field ::= non_second_primary_datetime_field [ '(' digit ')' ] | 'SECOND' [ '(' digit [ ',' digit ] ')' ]
non_second_primary_datetime_field ::= 'YEAR' | 'MONTH' | 'DAY' | 'HOUR' | 'MINUTE'
non_second_primary_datetime_field ::= 'YEAR' | 'MONTH' | 'DAY' | 'HOUR' | 'MINUTE'

generated_clause ::= 'GENERATED' ( ( ('ALWAYS' | 'BY' 'DEFAULT') 'AS' 'IDENTITY' ) | ('ALWAYS' 'AS' <<expr '-1'>>) )
5 changes: 4 additions & 1 deletion core/src/test/fixtures_hsql/column_types/Sample.s
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@ CREATE TABLE all_types(
some_interval2 INTERVAL YEAR(3),
some_interval3 INTERVAL DAY(4) TO HOUR,
some_interval4 INTERVAL MINUTE(4) TO SECOND(6),
some_interval5 INTERVAL SECOND(4,6)
some_interval5 INTERVAL SECOND(4,6),
some_always_generated_identity BIGINT GENERATED ALWAYS AS IDENTITY,
some_default_generated_identity BIGINT GENERATED BY DEFAULT AS IDENTITY,
some_always_generated_identity_primary_key BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY
);

0 comments on commit 4b3333e

Please sign in to comment.