Skip to content

Commit

Permalink
Fixes 4932 postgresql default constraint functions (#4934)
Browse files Browse the repository at this point in the history
* Support functions in default column definition

e.g

CREATE TABLE t1 (

  c1 UUID DEFAULT gen_random_uuid(),

  c2 INTEGER DEFAULT nextval('some_seq')

);

* Add simple fixture test
  • Loading branch information
griffio authored and hfhbd committed Apr 2, 2024
1 parent 4f54a9a commit 51b3321
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ default_constraint ::= [ NOT NULL | NULL ] DEFAULT (
current_timestamp_with_optional_interval |
{signed_number} |
{literal_value} |
{function_expr} |
LP <<expr '-1'>> RP
) {
extends = "com.alecstrong.sql.psi.core.psi.impl.SqlDefaultConstraintImpl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ CREATE TABLE all_types(

some_interval_d TIMESTAMP NOT NULL DEFAULT NOW() - INTERVAL '5 days',

some_interval_e INTERVAL DEFAULT INTERVAL '3h' + INTERVAL '20m'
some_interval_e INTERVAL DEFAULT INTERVAL '3h' + INTERVAL '20m',

some_default_uuid UUID DEFAULT gen_random_uuid(),

some_default_sequence INTEGER DEFAULT nextval('some_seq')

);

Expand Down

0 comments on commit 51b3321

Please sign in to comment.