Skip to content
Permalink
Browse files
Test for preserving fid map on clone
  • Loading branch information
m-kuhn authored and nyalldawson committed Jan 7, 2022
1 parent d78517e commit eadac075c874c2437eef5f21919d4d2497d69537
Showing with 16 additions and 0 deletions.
  1. +16 −0 tests/src/python/test_provider_postgres.py
@@ -1118,6 +1118,22 @@ def testPktMapInsert(self):
self.assertNotEqual(f[0]['obj_id'], NULL, f[0].attributes())
vl.deleteFeatures([f[0].id()])

def testClonePreservesFidMap(self):
vl = QgsVectorLayer(
'{} sslmode=disable srid=4326 key="pk" table="qgis_test".{} (geom)'.format(
self.dbconn, 'bigint_pk'),
"bigint_pk", "postgres")

# Generate primary keys
f = next(vl.getFeatures('pk = 2')) # 1
f = next(vl.getFeatures('pk = -1')) # 2
fid_orig = f.id()

clone = vl.clone()
f = next(clone.getFeatures('pk = -1')) # should still be 2
fid_copy = f.id()
self.assertEqual(fid_orig, fid_copy)

def testNull(self):
"""
Asserts that 0, '' and NULL are treated as different values on insert

0 comments on commit eadac07

Please sign in to comment.