pgschema
pgschema copied to clipboard
`CHECK (x IS NULL OR x IN (...))` generates unbalanced parentheses
Version: pgschema v1.6.1
Minimal reproduction
-- minimal.sql
CREATE TABLE test (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
status TEXT CHECK (status IS NULL OR status IN ('A', 'B', 'C'))
);
pgschema apply results in:
Plan: 1 to add.
Summary by type:
tables: 1 to add
Tables:
+ test
DDL to be executed:
--------------------------------------------------
CREATE TABLE IF NOT EXISTS test (
id uuid DEFAULT gen_random_uuid(),
status text,
CONSTRAINT test_pkey PRIMARY KEY (id),
CONSTRAINT test_status_check CHECK (status IS NULL OR (status IN ('A'::text, 'B'::text, 'C'::text))
);
Applying changes...
Executing group 1/1...
Executing 1 statements in implicit transaction
Error: failed to execute concatenated statements in group 1: ERROR: syntax error at or near ";" (SQLSTATE 42601)
When trying to reproduce it on main I found out that it has been already fixed in e2063b8ef52b60b4d0e165d7505ac16549d750a6 (#265). 😊