Skip to content
Permalink
Browse files

Add test to check identity field management

(cherry picked from commit 202f8a8)
  • Loading branch information
speillet authored and nyalldawson committed Jan 9, 2020
1 parent 6101c2e commit 254fff0852778665064af449a1f62f3e31d825bc
Showing with 31 additions and 1 deletion.
  1. +20 −1 tests/src/python/test_provider_oracle.py
  2. +11 −0 tests/testdata/provider/testdata_oracle.sql
@@ -389,7 +389,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')
@@ -436,5 +436,24 @@ def testGetFeatureFidInvalid(self):
feature = vl.getFeature(2)
self.assertTrue(feature.isValid())

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 254fff0

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