[Qgis-developer] wrong attribute values for postgis data in Feature attribute form

Mark Wynter mark at dimensionaledge.com
Thu Mar 26 03:43:12 PDT 2015


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 <r.nijssen at terglobo.nl>
> To: qgis-developer at lists.osgeo.org
> Subject: Re: [Qgis-developer] wrong attribute values for postgis data
> 	in Feature attribute form
> Message-ID: <5513DC52.8040006 at terglobo.nl>
> 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?)
> 



More information about the Qgis-developer mailing list