pgschema icon indicating copy to clipboard operation
pgschema copied to clipboard

Identifiers for index objects are not quoted where appropriate

Open whoward opened this issue 1 year ago • 1 comments

Continuing on with #59 we've found that when a index is created on a table with characters in the index name that would require the index name to be double quoted pgschema dump does not output the index name with double quoting. Here's an example:

create table some_table (
  id uuid primary key default gen_random_uuid(),
  position integer not null
);

create unique index "some table position index" on some_table (position);

and the output we get from pgschema dump is:

--
-- pgschema database dump
--

-- Dumped from database version PostgreSQL 17.0
-- Dumped by pgschema version 1.3.0


--
-- Name: some_table; Type: TABLE; Schema: -; Owner: -
--

CREATE TABLE IF NOT EXISTS some_table (
    id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
    position integer NOT NULL
);

--
-- Name: some table position index; Type: INDEX; Schema: -; Owner: -
--

CREATE UNIQUE INDEX IF NOT EXISTS some table position index ON some_table (position);

This is obviously syntactically incorrect, so the index name needs to be double quoted.

whoward avatar Oct 14 '25 15:10 whoward

just tested this change and it works great, thanks for taking care of that!

whoward avatar Oct 16 '25 15:10 whoward