Bug report #21670
DB Manager - load sql query as layer with primary key
|Category:||Python bindings / sipify|
|Affected QGIS version:||3.7(master)||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||duplicate|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||29486|
I use Win7 and Qgis 3.4 (or 3.6, the same bug appends)
I use DB manager for loading a layer in qgis.
If I do in the request dialog :
- "SELECT * FROM spatialite_table"
- or "SELECT * FROM spatialite_view"
Then I check "Load as a new layer", And I check "primary key column" with the column I want for the primary key.
It seems ok, the layer is loaded in qgis, and in properties/source there is
dbname='path_to_spatialite_file' key='column_with_pk_i_want' table="spatialite_table" (geom) sql=
But When I do with pyqgis :
print([fet.id() for fet in the_qgis_layer.getFeatures()])
it's printing the first column value of the spatialite_table, and not the 'column_with_pk_i_want' column value...
It was working well in qgis 2.18.
Thanks in advance,