Bug report #4969

Postgis Primary key

Added by Luca Lanteri over 8 years ago. Updated about 8 years ago.

Status:Closed
Priority:Normal
Assignee:Jürgen Fischer
Category:Data Provider/PostGIS
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:14758

Description

Hi,
with latest version of QGIS master (1.9.90.56) when I load a postGIS view select the primary key column from combobox is mandatory, whereas with previous version (surely back from 1.9.90.23), if a valid primary exists it was automatically recognized.

Associated revisions

History

#1 Updated by Luca Lanteri over 8 years ago

A possible solution may be to select the first integer valid primary key. User can also select a different field using the combobox.

#2 Updated by Jürgen Fischer over 8 years ago

  • Status changed from Open to Feedback

mescal72 - wrote:

A possible solution may be to select the first integer valid primary key. User can also select a different field using the combobox.

The primary key detection wasn't really reliable before. Being a primary key in the underlying table doesn't necessarily make the columns values unique in the view - and detecting which of the integer columns are unique can be quite expensive.

What's the problem with having the user select the primary key?

#3 Updated by Giuseppe Sucameli over 8 years ago

Jürgen Fischer wrote:

What's the problem with having the user select the primary key?

It could be quite annoying...

Why do not pre-select the combo with the first suitable field returned by the view?
So users can define what field use as default pk for views just changing the view definition.

#4 Updated by Giuseppe Sucameli over 8 years ago

Furthermore in this moment the user cannot run the query builder before he defines what's the primary key to use for the view (because the view cannot be selected if no primary key is set).

#5 Updated by Alessandro Ciali over 8 years ago

I don't know if it is pertaining to this issue, but from version 1.9.90.23 the OID is no more recognised as primary key for the view. Is is a bug or a wanted change?

#6 Updated by Jürgen Fischer over 8 years ago

  • Resolution set to fixed
  • Status changed from Feedback to Closed

fixed in d2b5ed92

#7 Updated by Giuseppe Sucameli about 8 years ago

  • Resolution deleted (fixed)
  • Status changed from Closed to Open

The problem occurs again (regression?).
The first primary key for views is not pre-selected, on Ubuntu 11.04 and QGis 1.8 d1cb3f3fa.

#8 Updated by Giuseppe Sucameli about 8 years ago

  • Priority changed from Normal to Severe/Regression

Blocker as policy for regressions.

#9 Updated by Giuseppe Sucameli about 8 years ago

The behavior was changed in 494561167 probably because if the the first suitable pkey is pre-selected the user doesn't notice the view has more pkeys.

Even though the user doesn't select any pkey from the dropdown list a view with more suitable pkeys should be selectable.
If the user loads that view w/o selecting the pkey, QGis should just use the first one in the list.

#10 Updated by Jürgen Fischer about 8 years ago

  • Crashes QGIS or corrupts data set to No
  • Tracker changed from Feature request to Bug report
  • Status changed from Open to Closed
  • Assignee set to Jürgen Fischer
  • Priority changed from Severe/Regression to Normal
  • Resolution set to fixed
  • Affected QGIS version set to master

Giuseppe Sucameli wrote:

The problem occurs again (regression?).
The first primary key for views is not pre-selected, on Ubuntu 11.04 and QGis 1.8 d1cb3f3fa.

The mandatory selection of a primary key is intentional. QGIS just lists all integer fields without caring if they are derived from some primary key or uniquely indexed table field anymore - because that doesn't tell you anything about their uniqueness in the view anyway. The user needs to decide - QGIS will just verify that the selected key is unique (unless "use estimated table metadata" is used).

The valid bug was that oid wasn't considered anymore - and that was fixed.

1.7 projects already have a key field for views in their datasource uri and continue to work - so I don't consider this a regression.

#11 Updated by Luca Lanteri about 8 years ago

Ok, but the result is that now I must do a lot of clicks to load multiple views 'cause I have to select all single gid for every view. This is formally correct but from the user's point of view is a very annoying regression.
I really don't understand why is impossible to have the fist gid candidate as default value in the combobox. If this column is not unique a message box can prompt the user and the right column can be selected, but if the view is well structured I can save a lot of time.
It's just a piece of advice from an user.

#12 Updated by Jürgen Fischer about 8 years ago

  • Resolution deleted (fixed)
  • Status changed from Closed to Reopened

#13 Updated by Jürgen Fischer about 8 years ago

  • Status changed from Reopened to Closed

Also available in: Atom PDF