Bug report #7944

addFeatures in provider does not return properly the feature ID

Added by Denis Rouzaud almost 11 years ago. Updated almost 11 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:Matthias Kuhn
Category:Vectors
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:16811

Description

In python, when doing:
ans, fout = provider.addFeatures( [fin] )

The feature fin is properly added, but doing fout[0].id() returns 0.

In postgres, the feature is created and has a different ID.

It is a regression because it used to work.

The same problem existed before but was solved in 7028827

History

#1 Updated by Matthias Kuhn almost 11 years ago

I had a look at this today. It's quite strange, because the result is assigned in the provider and the proper id is still available from sip.
It looks as if a copy of the featurelist is passed to the dataprovider, where the proper id is assigned, but then the copy is deleted without the results being mapped back to the python object.
I also couldn't find any commits which would have changed related code.
Can you tell me the last working version?

#2 Updated by Jürgen Fischer almost 11 years ago

  • Assignee changed from Jürgen Fischer to Matthias Kuhn

#3 Updated by Denis Rouzaud almost 11 years ago

It used to work after this commit 7028827 (and probaby until before new API?)

#5 Updated by Denis Rouzaud almost 11 years ago

  • Status changed from Open to Closed

forgot to call initAttributes after setFields.

so no bug at all.

#6 Updated by Matthias Kuhn almost 11 years ago

initAttributes is now issued automatically when calling setFields from python.

Also available in: Atom PDF