Opened 15 years ago
Closed 15 years ago
#1417 closed bug (duplicate)
Unable to add a Postgis layer when the key attribut have an alias
Reported by: | mgrizonnet | Owned by: | nobody |
---|---|---|---|
Priority: | major: does not work as expected | Milestone: | Version 1.0.3 |
Component: | Data Provider | Version: | Trunk |
Keywords: | postgis layer/primary key/alias | Cc: | |
Must Fix for Release: | No | Platform: | Windows |
Platform Version: | Awaiting user input: | no |
Description
I created 2 views VIEW _VIEW0 and VIEW _VIEW1 in PostgreSQL.
The code:
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!!!!
Change History (3)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
Just tested with:
mipi=> create view view1 as select cat, the_geom from fix where cat=2531; CREATE VIEW mipi=> create view view2 as select cat as id, the_geom from fix where cat=2531; CREATE VIEW
and QGIS can load both layers without hassle: can you please check again and report back?
comment:3 by , 15 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Probably a duplicate of #1718
See also #1545 (now closed as it's a duplicate)