HypoPG / hypopg

Hypothetical Indexes for PostgreSQL
https://hypopg.readthedocs.io
Other
1.39k stars 59 forks source link

column names not quoted in `hypopg_get_indexdef` #87

Closed olirice closed 6 months ago

olirice commented 7 months ago

When creating hypothetical indexes on column names that are camelCase or have special characters, the output of hypopg_get_indexdef is not quoted, leading to an invalid create index statement.

Reproducible case:

create extension if not exists hypopg;

create table public."Book"("Id" int primary key);
SELECT indexdef FROM pg_indexes
-- CREATE UNIQUE INDEX "Book_pkey" ON public."Book" USING btree ("Id")

SELECT hypopg_create_index('create index on public."Book" ("Id")');
select hypopg_get_indexdef(indexrelid) from hypopg();
-- CREATE INDEX ON public."Book" USING btree (Id)

Note that the definition of the Postgres native index from pg_indexes quotes ("Id") while the index definition on the same column using hypopg does not (Id)

Originally reported in https://twitter.com/mavrickmaster/status/1780570245952135286

rjuju commented 7 months ago

Thanks for the report!

Indeed, the attribute name missed proper quoting, so was the attributes in the INCLUDE clause. Commit https://github.com/HypoPG/hypopg/commit/d102c8a6400f26ad33e72a42cbba9fad390e1332 should fix the problem.

olirice commented 7 months ago

that's fantastic, thank you for the quick turnaround

any chance I could hassle you for a 1.4.1 release so we can roll the update out on Supabase?

olirice commented 6 months ago

friendly bump on ^

if not feasible, feel free to close this issue as completed

rjuju commented 6 months ago

I'm planning to do a release soon, but it's unfortunately quite a bit of work and I've been quite busy recently with multiple other projects (including the one I use to provide the windows installer for each release of hypopg).

I was planning to keep this issue opened as a reminder for the release, but if you prefer to close it feel free to do so.

rjuju commented 6 months ago

I just released version 1.4.1! I'm closing this issue now.