pgschema icon indicating copy to clipboard operation
pgschema copied to clipboard

column default expression sometimes generate invalid syntax

Open whoward opened this issue 1 year ago • 1 comments

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'.

whoward avatar Oct 16 '25 15:10 whoward

just checked, this works great - thanks for taking care of that!

whoward avatar Oct 19 '25 13:10 whoward