Bug report #14813

Add PostGIS view -- primary key is ignored

Added by Thomas Kandler almost 8 years ago. Updated almost 8 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Data Provider
Affected QGIS version:2.14.0 Regression?:No
Operating System:Windows Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:22769

Description

When loading a PostGIS view with a primary key, the key should be choosen automatically (by using the first column I guess). In QGIS 2.8 this was possible, since 2.12 the function does not exist anymore. Maybe it is a deliberate change to avoid errors when loading a layer which turns out to have non-unique values in this column. Maybe it is a bug. In the first case, I'd second #14367

This affects views with an unique integer column (+ all other columns are string-type) as well as views with a singular string column (+ geom column).

Add_PostGIS_Table_s_.jpg - QGIS 2.8 (86.2 KB) Thomas Kandler, 2016-05-13 06:04 AM

Add_PostGIS_Table_s__2.jpg - QGIS 2.14 (88.9 KB) Thomas Kandler, 2016-05-13 06:04 AM

History

#1 Updated by Jürgen Fischer almost 8 years ago

The arbitray pre-selection of the first column is gone. You are now required to select the primary keys (one or more columns).

#2 Updated by Thomas Kandler almost 8 years ago

Jürgen Fischer wrote:

The arbitray pre-selection of the first column is gone. You are now required to select the primary keys (one or more columns).

Any rationale for this? I am just wondering since even a arbitrary selection would be as efficient as the mandatory selection at worst; and in many cases more efficient since I save 2 clicks per layer/view.

P.S. Issue can be closed; I will do asap.

#3 Updated by Thomas Kandler almost 8 years ago

  • Status changed from Open to Closed

#4 Updated by Jürgen Fischer almost 8 years ago

Thomas Kandler wrote:

Jürgen Fischer wrote:

The arbitray pre-selection of the first column is gone. You are now required to select the primary keys (one or more columns).

Any rationale for this? I am just wondering since even a arbitrary selection would be as efficient as the mandatory selection at worst; and in many cases more efficient since I save 2 clicks per layer/view.

QGIS doesn't know what the unique column is and was always supposed to be selected. The preselection was hiding this and led to reports of strange effects when it wasn't unique.

#5 Updated by Thomas Kandler almost 8 years ago

Jürgen Fischer wrote:

QGIS doesn't know what the unique column is and was always supposed to be selected. The preselection was hiding this and led to reports of strange effects when it wasn't unique.

Thank you very much for the clarification. I'd taken another approach but I am also not a contributing dev. Anyhow, I guess #14367 could be a well worth investment for folks who have a lot of PostGIS views (spanning multiple DBs) in their everyday work.

Also available in: Atom PDF