Skip to content

Commit

Permalink
Make TestPyQgsPostgresProvider.testPktFloatingPoint idempotent
Browse files Browse the repository at this point in the history
References qgis#45417
  • Loading branch information
strk committed Oct 5, 2021
1 parent 8f71e3d commit bb30046
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/src/python/test_provider_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,11 @@ def testPktFloatingPoint(self):
"""
Check if we can handle floating point/numeric primary keys correctly
"""

# 0. Backup test table (will be edited)
self.backupTable('qgis_test', 'tb_test_float_pk')
self.backupTable('qgis_test', 'tb_test_double_pk')

# 1. 32 bit float (PostgreSQL "REAL" type)
vl = QgsVectorLayer(self.dbconn + ' sslmode=disable srid=4326 key="pk" table="qgis_test"."tb_test_float_pk" (geom)', "test_float_pk", "postgres")
self.assertTrue(vl.isValid())
Expand Down Expand Up @@ -1084,6 +1089,10 @@ def testPktFloatingPoint(self):
# no NUMERIC/DECIMAL checks here. NUMERIC primary keys are unsupported.
# TODO: implement NUMERIC primary keys/arbitrary precision arithmethics/fixed point math in QGIS.

# Restore test tables
self.restoreTable('qgis_test', 'tb_test_float_pk')
self.restoreTable('qgis_test', 'tb_test_double_pk')

def testPktMapInsert(self):
vl = QgsVectorLayer('{} table="qgis_test"."{}" key="obj_id" sql='.format(self.dbconn, 'oid_serial_table'),
"oid_serial", "postgres")
Expand Down

0 comments on commit bb30046

Please sign in to comment.