To add my 2 cents worth, I now habitually add a default INTEGER field to my PostGIS views to provide QGIS with a unique identifier. I label this field ‘qid’ so as not to confuse it with potentially other unique keys that may already exist in the underlying data.
For example: CREATE OR REPLACE VIEW myview AS (WITH s AS (SELECT poly_id, (ST_Dump(wkb_geometry)).geom::geometry(Polygon, 4326) as the_geom FROM mytable ORDER BY 1) SELECT row_number() over() as qid, s.* FROM s); Kind regards Mark > Message: 8 > Date: Thu, 26 Mar 2015 11:15:46 +0100 > From: Raymond Nijssen <[email protected]> > To: [email protected] > Subject: Re: [Qgis-developer] wrong attribute values for postgis data > in Feature attribute form > Message-ID: <[email protected]> > Content-Type: text/plain; charset=utf-8; format=flowed > > Thanks Bernhard. I just figured that. But my layer is not a table, it is > a view. And it seems that PostgreSQL cannot have constraints on views. > > So, I think I just need to carefully select the right key field when > loading it. > > (And maybe QGIS could be slightly smarter by not suggesting a boolean > field by default?) > _______________________________________________ Qgis-developer mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-developer
