Please sign in to comment.
Memory provider: roll back on errors
Long story short: calling provider's addFeatures is implemented for some providers in a way that will roll back all changes on errors, leaving the backend storage unchanged. Adding a QgsFeatureSink flag to control this behavior allows certain providers to support partial feature addition. The issue comes from QgsVectorDataProvider::commitChanges that is documented to leave the provider unchanged (roll back) on any error, giving the client code the possibility to fix errors (in the editing buffer) and re-commit. Without a full rollback implementation in the memory provider and after the type check introduction in this PR we ended up with situations like this: vl = ... an empty memory layer self.assertTrue(vl.addFeatures([valid, invalid])) self.assertFalse(vl.commitChanges()) self.assertEqual(vl.featureCount(), 1) <--- fails! We actually had 3 features from vl.getFeatures(): [valid, invalid, valid] (the first from the provider the second and third from the editing buffer). On the other hand, QgsFeatureSink would probably assume that addFeatures will allow partial additions. BTW: This is for sure the longest commit message I've ever written.
- Loading branch information
Showing with 186 additions and 18 deletions.