martinjw/dbschemareader

PostgreSQL: DatabaseIndex.IsUnique is always false when loaded from database

Arnagos opened this issue · 2 comments

When loading a schema from a PostgreSQL database the IsUnique property on indices is always false.

The index was created with this SQL:

CREATE UNIQUE INDEX "Punchclock__Company_CeoId_idx" ON "Punchclock__Company"("CeoId");

And prompting the database to generate a creation script generates this SQL:

CREATE UNIQUE INDEX IF NOT EXISTS "Punchclock__Company_CeoId_idx"
    ON public."Punchclock__Company" USING btree
    ("CeoId" ASC NULLS LAST)
    TABLESPACE pg_default;

Based on this I'm pretty sure it's a loader issue.

Seems like the Loader does not set this value for PostgreSQL.

The query set in the constructor of the same class doesn't even request the required column.

Adding ix.indisunique as index_is_unique, to the select should provide the necessary value for this.
And if you want to ignore the primary key indices ix.indisprimary as index_is_primary, should help.

image

I just noticed that the index type is not set either. Maybe ix.indisclustered can help with this?