pgschema
pgschema copied to clipboard
column default expression sometimes generate invalid syntax
When we apply a default value that includes some kind of more complex expression pgschema dump seems to generate invalid SQL. Here is the example I have:
create table some_table (
id serial primary key,
created_at timestamp without time zone default (now() at time zone 'utc') not null
);
This table definition generates the following SQL with pgschema dump
--
-- pgschema database dump
--
-- Dumped from database version PostgreSQL 17.0
-- Dumped by pgschema version 1.4.0
--
-- Name: some_table; Type: TABLE; Schema: -; Owner: -
--
CREATE TABLE IF NOT EXISTS some_table (
id SERIAL,
created_at timestamp DEFAULT (now() AT TIME ZONE 'utc' NOT NULL,
CONSTRAINT some_table_pkey PRIMARY KEY (id)
);
Notice the lack of a closing bracket after AT TIME ZONE 'utc'.
just checked, this works great - thanks for taking care of that!