Skip to content

Commit

Permalink
Test for preserving fid map on clone
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn authored and nyalldawson committed Jan 7, 2022
1 parent d78517e commit eadac07
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/src/python/test_provider_postgres.py
Expand Up @@ -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
Expand Down

0 comments on commit eadac07

Please sign in to comment.