Bug report #21397
Assigning a primary key in QgsDataSourceUri doesn't work
|Category:||Python bindings / sipify|
|Affected QGIS version:||3.4.5||Regression?:||Yes|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||29214|
I use qgis 3.4.5 with windows 7 64bit.
I build a qgsvectorlayer like this :
uri = qgis.core.QgsDataSourceUri()
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 nicely in 2.18....
thank you in advance,
#1 Updated by Giovanni Manghi 9 months ago
- Subject changed from Assigning a primary key in QgsDataSourceUri doesn't work :/ to Assigning a primary key in QgsDataSourceUri doesn't work
- Category changed from DB Manager to Python bindings / sipify
- Status changed from Open to Feedback
Have you asked in the developers mailing list if anything changed about what this is done in 3.*?
#5 Updated by Giovanni Manghi 9 months ago
- Status changed from Feedback to Open
Patrice V wrote:
I've asked a subsription 2 weeks ago and I still not have a mail to confirm...
I'm sure it is a regression...
the process to subscribe/unsubscribe the lists is not manually reviewed, you should receive an confirmation email, with a link.
#7 Updated by Alessandro Pasotti 9 months ago
Patrice V wrote:
it's been 6 days I've made a post and nobody replies :(
it's blocking me for porting a plugin to qgis 3
What should I do ?
Perhaps you could get some useful ideas from this article: