Bug report #1987
Layer with partial unique index are wrong handeld
|Affected QGIS version:||Regression?:||No|
|Operating System:||RedHat||Easy fix?:||No|
|Pull Request or Patch supplied:||Resolution:||fixed|
|Crashes QGIS or corrupts data:||Copied to github as #:||12047|
If you have a postgis point table with a partial unique index like
CREATE UNIQUE INDEX foo_bar_unique_idx ON foo USING btree (bar) WHERE archive = 0;
it looks like qgis isn't using the primary key of the table but the partial unique index. The index though isn't unique. It's only unique for the rows in the where condition.
The following problems I detected on such a table:
- the attribute table fails on sorting
- the identify tool sometimes marks a false point
- the select tool selects more as the expected points
- if you edit an affected point, the false point/row is edited
I only tested for a point layer. Maybe there is the same issue with lines and polygons.
Attached is a dump of a sample table with 3 points and a partial index that leads to the problems here. I may provide other/bigger sample data if necessary.