Bug report #1417
Unable to add a Postgis layer when the key attribut have an alias
|Affected QGIS version:||Regression?:||No|
|Operating System:||Windows||Easy fix?:||No|
|Pull Request or Patch supplied:||Resolution:||duplicate|
|Crashes QGIS or corrupts data:||Copied to github as #:||11477|
I created 2 views VIEW _VIEW0 and VIEW _VIEW1 in PostgreSQL.
CREATE OR REPLACE VIEW _VIEW0 AS SELECT t1.geom, t1.id FROM table1 t1 ORDER BY t1.id;
CREATE OR REPLACE VIEW _VIEW0 AS SELECT t1.geom, t1.id as id_geo FROM table1 t1 ORDER BY t1.id;
It is the same views. The only difference is that the attribute "id" has got an "alias" (the alias is "id_geo").
The data type of id is int4 and it is a primary key (needed by QGIS to make the connection).
The first view works well but not the second. The message returned by QGIS is that the attribute "id" is not a primary key (data not unique).
But it is the same views!!!!
#2 Updated by Paolo Cavallini over 11 years ago
Just tested with:
mipi=> create view view1 as select cat, the_geom from fix where cat=2531;
mipi=> create view view2 as select cat as id, the_geom from fix where cat=2531;
and QGIS can load both layers without hassle: can you please check again and report back?