Bug report #13341

DBManager doesn't import view from table with non numeric key

Added by Moreno Comelli over 7 years ago. Updated almost 4 years ago.

Category:DB Manager
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:end of life
Crashes QGIS or corrupts data:No Copied to github as #:21394


DBManager can import without any problem PostGIS geometries with non numeric Primary Key.
When a view is made from a such kind of table:

CREATE OR REPLACE VIEW my_schema.my_view AS
SELECT * FROM my_schema.my_table;

it can be imported correctly using the tool 'Add PostGIS layer' (after choosing the primary key column).
DBManager doesn't display the geometry in the preview window, and when trying to import it alerts 'The layer is not a valid layer and can not be added to the map'.

I've already seen Bug report #11317; the problem is related to DBManager, since QGIS can manage it, so it doesn't depend on unique key.

Related issues

Related to QGIS Application - Bug report #13670: DBManager selects wrong field as key when loading view fr... Closed 2015-10-25


#1 Updated by Sebastian Dietrich over 7 years ago

DBManager basically uses the first numeric column as the key for a view. See also #13670.
The solution would be the same: Ask the user what column(s) to use as the primary key.

#2 Updated by Giovanni Manghi about 7 years ago

  • Affected QGIS version changed from 2.10.1 to master
  • Operating System deleted (Windows)
  • OS version deleted (8.1)

#3 Updated by Giovanni Manghi about 7 years ago

see also #13670

#4 Updated by Giovanni Manghi almost 6 years ago

  • Regression? set to No
  • Easy fix? set to No

#5 Updated by Giovanni Manghi almost 4 years ago

  • Resolution set to end of life
  • Status changed from Open to Closed

Also available in: Atom PDF