Skip to content

Commit 4e3abbc

Browse files
committed
Add test
1 parent 76c0a5b commit 4e3abbc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/src/python/test_provider_postgres.py

+23
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,29 @@ def testTimeout(self):
355355
for i in range(100):
356356
iterators.append(self.vl.getFeatures(request))
357357

358+
def testTransactionDirtyName(self):
359+
# create a vector ayer based on postgres
360+
vl = QgsVectorLayer(self.dbconn + ' sslmode=disable key=\'pk\' srid=4326 type=POLYGON table="qgis_test"."some_poly_data" (geom) sql=', 'test', 'postgres')
361+
self.assertTrue(vl.isValid())
362+
363+
# prepare a project with transactions enabled
364+
p = QgsProject()
365+
p.setAutoTransaction(True)
366+
p.addMapLayers([vl])
367+
vl.startEditing()
368+
369+
# update the data within the transaction
370+
tr = vl.dataProvider().transaction()
371+
sql = "update qgis_test.some_poly_data set pk=1 where pk=1"
372+
name = "My Awesome Transaction!"
373+
self.assertTrue(tr.executeSql(sql, True, name)[0])
374+
375+
# test name
376+
self.assertEqual(vl.undoStack().command(0).text(), name)
377+
378+
# rollback
379+
vl.rollBack()
380+
358381
def testTransactionDirty(self):
359382
# create a vector layer based on postgres
360383
vl = QgsVectorLayer(self.dbconn + ' sslmode=disable key=\'pk\' srid=4326 type=POLYGON table="qgis_test"."some_poly_data" (geom) sql=', 'test', 'postgres')

0 commit comments

Comments
 (0)