Bug report #21397
Assigning a primary key in QgsDataSourceUri doesn't work
Status: | Open | ||
---|---|---|---|
Priority: | High | ||
Assignee: | - | ||
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 |
Description
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 nicely in 2.18....
thank you in advance,
Related issues
History
#1 Updated by Giovanni Manghi over 5 years 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.*?
#2 Updated by Patrice V over 5 years ago
Hi,
The moderator of the mailing list doesn't let me post a question... I really believe it is a bug and not an expected behaviour...
Regards,
#3 Updated by Giovanni Manghi over 5 years ago
Patrice V wrote:
Hi,
The moderator of the mailing list doesn't let me post a question... I really believe it is a bug and not an expected behaviour...
Regards,
have you subscribed the list? if not is normal your messages get bumped.
#4 Updated by Patrice V over 5 years ago
Hi,
I've asked a subsription 2 weeks ago and I still not have a mail to confirm...
I'm sure it is a regression...
Regards,
#5 Updated by Giovanni Manghi over 5 years ago
- Status changed from Feedback to Open
Patrice V wrote:
Hi,
I've asked a subsription 2 weeks ago and I still not have a mail to confirm...
I'm sure it is a regression...
Regards,
the process to subscribe/unsubscribe the lists is not manually reviewed, you should receive an confirmation email, with a link.
#6 Updated by Patrice V over 5 years ago
Hi,
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 ?
Thanks,
#7 Updated by Alessandro Pasotti over 5 years ago
Patrice V wrote:
Hi,
it's been 6 days I've made a post and nobody replies :(
it's blocking me for porting a plugin to qgis 3What should I do ?
Perhaps you could get some useful ideas from this article:
https://nyalldawson.net/2016/08/how-to-effectively-get-things-changed-in-qgis/
#8 Updated by Alessandro Pasotti over 5 years ago
- Duplicated by Bug report #21670: DB Manager - load sql query as layer with primary key added