Skip to content
Permalink
Browse files

Add test to check identity field management

  • Loading branch information
speillet authored and nyalldawson committed Jan 9, 2020
1 parent efdb8d1 commit 32ebc12d82e2fd6c2d412dd168a2e25ec4ec967d
Showing with 30 additions and 1 deletion.
  1. +19 −1 tests/src/python/test_provider_oracle.py
  2. +11 −0 tests/testdata/provider/testdata_oracle.sql
@@ -588,7 +588,7 @@ def testTransactionDirty(self):
vl.rollBack()

def testTransactionTuple(self):
# create a vector layer based on postgres
# create a vector layer based on oracle
vl = QgsVectorLayer(
self.dbconn + ' sslmode=disable key=\'pk\' srid=4326 type=POLYGON table="QGIS"."SOME_POLY_DATA" (GEOM) sql=',
'test', 'oracle')
@@ -608,6 +608,24 @@ def testTransactionTuple(self):
# underlying data has not been modified
self.assertFalse(vl.isModified())

def testIdentityCommit(self):
# create a vector layer based on oracle
vl = QgsVectorLayer(
self.dbconn + ' sslmode=disable key=\'pk\' srid=4326 type=POINT table="QGIS"."POINT_DATA_IDENTITY" (GEOM) sql=',
'test', 'oracle')
self.assertTrue(vl.isValid())

features = [f for f in vl.getFeatures()]

# add a new feature
newf = QgsFeature(features[0].fields())
success, featureAdded = vl.dataProvider().addFeatures([newf])
self.assertTrue(success)

# clean up
features = [f for f in vl.getFeatures()]
vl.dataProvider().deleteFeatures([features[-1].id()])


if __name__ == '__main__':
unittest.main()
@@ -68,4 +68,15 @@ CREATE TABLE QGIS.DATE_TIMES ( "id" INTEGER PRIMARY KEY, "date_field" DATE, "dat

INSERT INTO QGIS.DATE_TIMES ("id", "date_field", "datetime_field" ) VALUES (1, DATE '2004-03-04', TIMESTAMP '2004-03-04 13:41:52' );

CREATE TABLE QGIS.POINT_DATA_IDENTITY ( "pk" NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, GEOM SDO_GEOMETRY);
INSERT INTO QGIS.POINT_DATA_IDENTITY (GEOM)
SELECT SDO_GEOMETRY( 2001,4326,SDO_POINT_TYPE(1, 2, NULL), NULL, NULL) from dual
UNION ALL SELECT SDO_GEOMETRY( 3001,4326,SDO_POINT_TYPE(1, 2, 3), NULL, NULL) from dual
UNION ALL SELECT SDO_GEOMETRY( 3005,4326,NULL, sdo_elem_info_array (1,1,1, 4,1,1), sdo_ordinate_array (1,2,3, 4,5,6)) from dual
UNION ALL SELECT SDO_GEOMETRY( 2005,4326,NULL, sdo_elem_info_array (1,1,1, 3,1,1), sdo_ordinate_array (1,2, 3,4)) from dual
UNION ALL SELECT SDO_GEOMETRY( 3005,4326,NULL, sdo_elem_info_array (1,1,2), sdo_ordinate_array (1,2,3, 4,5,6)) from dual
UNION ALL SELECT SDO_GEOMETRY( 2001,4326,NULL, sdo_elem_info_array (1,1,1), sdo_ordinate_array (1,2)) from dual
UNION ALL SELECT SDO_GEOMETRY( 2001,4326, SDO_POINT_TYPE(3, 4, NULL), NULL, NULL) from dual
UNION ALL SELECT SDO_GEOMETRY( 2001,4326,NULL, sdo_elem_info_array (1,1,1), sdo_ordinate_array (5,6)) from dual;

COMMIT;

0 comments on commit 32ebc12

Please sign in to comment.
You can’t perform that action at this time.