[Qgis-user] QGIS 2.10.1 adding PostGIS Views

Jürgen E. Fischer jef at norbit.de
Tue Sep 1 13:18:34 PDT 2015


Hi James,

On Tue, 01. Sep 2015 at 08:50:27 -0400, James Keener wrote:
> At the very least, don't tell people to use ROW_NUMBER() as a primary
> key.  This is just terrible advice!

FTR I didn't suggest using row_number().

> Also, I'm running 2.10.1 and when I add a view on a table with no unique
> values, and even if I select a non-unique field as my primary key, QGIS
> will happily load the view, not complain about the cardinality of the
> "primary key" being less than the carnality of the rows, and proceed to
> draw the geometries correctly and let me select features and will show
> me the correct attributes. 

You are using "use estimated metadata"?  Otherwise QGIS should have checked if
the selected pk is actually unique.   And you will only notice that there is
something wrong when you select features that have a non unique key.

> Now, go to QGIS, select column 'a' as the "primary key".  You'll see 3
> points, and you'll be able to get the correct attribute values for each

Because the features are retrieved by geometry and not by key in identify.

Select a feature and you'll find that selecting one will select all - because
we just store that feature id 1 was selected.

And as we usually don't cache features we have nothing to tie some sort of
internally generate key to the feature.

> If tables can be used without selecting a primary key, why must views?

Because for tables we can use ctid as last resort - but not that also makes
layers readonly.


Jürgen

-- 
Jürgen E. Fischer           norBIT GmbH             Tel. +49-4931-918175-31
Dipl.-Inf. (FH)             Rheinstraße 13          Fax. +49-4931-918175-50
Software Engineer           D-26506 Norden             http://www.norbit.de
QGIS release manager (PSC)  Germany                    IRC: jef on FreeNode                         
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 827 bytes
Desc: Digital signature
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20150901/1ecdb33c/attachment.sig>


More information about the Qgis-user mailing list