[QGIS-Developer] Assigning a primary key in QgsDataSourceUri doesn't work

pat31 patverch at yahoo.fr
Thu Mar 14 07:54:20 PDT 2019


Hi devs,

I use qgis 3.4.5 with windows 7 64bit.

I build a qgsvectorlayer like this :
uri = qgis.core.QgsDataSourceUri()
uri.setDatabase('a_sqlite_file')
uri.setDataSource('', 'SELECT * FROM MyTable', 'geom'
,'','the_pk_column_name')
vlayer = qgis.core.QgsVectorLayer(uri.uri(), tablename, 'spatialite')

When I ask the id of the features in vlayer ([fet.id() for fet in
vlayer.getFeatures()]), it returns the value of the first column of
'MyTable', and not the value of the 'the_pk_column_name' column...

it was working in 2.18. Could you confirm it is a regression and not a
normal behaviour ?

Regards,



--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-Developer-f4099106.html


More information about the QGIS-Developer mailing list