Feature request #16527

Handle absent primary keys for postgresql views in add postgis layer dialog

Added by Nikolay Lebedev over 3 years ago. Updated over 3 years ago.

Status:Feedback
Priority:Normal
Assignee:-
Category:Data Provider/PostGIS
Pull Request or Patch supplied:No Resolution:
Easy fix?:No Copied to github as #:24433

Description

When adding data from postgresql (materialized) view QGIS add layer dialog always shows exclamation mark icon due to missing primary key. But there is no way to set PK on a view in postgres. Can UI be tweaked a bit for this case?

History

#1 Updated by Giovanni Manghi over 3 years ago

  • Category changed from GUI to Data Provider/PostGIS

Meantime if you need a column with unique values:

SELECT row_number() OVER () AS id ...

#2 Updated by Regis Haubourg over 3 years ago

Not sure to understand, you have a column to choose the unique id field(s) in the Connection dialog.
Did you miss it ?

#3 Updated by Giovanni Manghi over 3 years ago

  • Status changed from Open to Feedback

#4 Updated by Nikolay Lebedev over 3 years ago

I have a column with unique values in my views, I just don't like to set it every time I need to add a view as a layer. Maybe there can be a convention of using "default" names for PK columns - like "id" or "gid"? Maybe postgresql comments can be utilized? Like setting a keyword in a comment. So QGIS should automatically "guess" the PK column.

So I definitely didn't miss a column in the Connection dialog:) I just want to avoid going into it and setting the same column name as a PK every time I want to add something to my QGIS project:))

Also available in: Atom PDF