Skip to content
Permalink
Browse files

Merge pull request #40107 from rduivenvoorde/39855_diminfo_param_take2

Fix for diminfo as string in Oracle mdsys metadata query
  • Loading branch information
m-kuhn committed Nov 20, 2020
2 parents 78825cf + ed53ea5 commit ca637cfeb2810d0863b9168c2f3c07fb615440cc
Showing with 21 additions and 3 deletions.
  1. +2 −2 src/providers/oracle/qgsoracleprovider.cpp
  2. +19 −1 tests/src/python/test_provider_oracle.py
@@ -3093,8 +3093,8 @@ QgsVectorLayerExporter::ExportError QgsOracleProvider::createEmptyLayer(
}
}

if ( !exec( qry, QString( "INSERT INTO mdsys.user_sdo_geom_metadata(table_name,column_name,srid,diminfo) VALUES (?,?,?,?)" ),
QVariantList() << tableName.toUpper() << geometryColumn.toUpper() << srid << diminfo ) )
if ( !exec( qry, QStringLiteral( "INSERT INTO mdsys.user_sdo_geom_metadata(table_name,column_name,srid,diminfo) VALUES (?,?,?,%1)" ).arg( diminfo ),
QVariantList() << tableName.toUpper() << geometryColumn.toUpper() << srid ) )
{
throw OracleException( tr( "Could not insert metadata." ), qry );
}
@@ -24,7 +24,10 @@
QgsFeature,
QgsGeometry,
QgsWkbTypes,
QgsDataProvider
QgsDataProvider,
QgsVectorLayerExporter,
QgsFields,
QgsCoordinateReferenceSystem
)

from qgis.PyQt.QtCore import QDate, QTime, QDateTime, QVariant
@@ -819,6 +822,21 @@ def testEvaluateDefaultValues(self):
attributes = [feat.attributes() for feat in vl.getFeatures()]
self.assertEqual(attributes, [[1, 'qgis'], [2, 'test'], [3, 'qgis'], [4, 'test']])

def testCreateEmptyLayer(self):
uri = self.dbconn + "srid=4326 type=POINT table=\"EMPTY_LAYER\" (GEOM)"
exporter = QgsVectorLayerExporter(uri=uri, provider='oracle', fields=QgsFields(), geometryType=QgsWkbTypes.Point, crs=QgsCoordinateReferenceSystem(4326), overwrite=True)
self.assertEqual(exporter.errorCount(), 0)
self.assertEqual(exporter.errorCode(), 0)
# check IF there is an empty table (will throw error if the EMPTY_LAYER table does not excist)
self.execSQLCommand('SELECT count(*) FROM "QGIS"."EMPTY_LAYER"')
vl = QgsVectorLayer(
self.dbconn + ' sslmode=disable table="QGIS"."EMPTY_LAYER" sql=',
'test', 'oracle')
self.assertTrue(vl.isValid())
# cleanup
self.execSQLCommand('DROP TABLE "QGIS"."EMPTY_LAYER"')
self.execSQLCommand("DELETE FROM user_sdo_geom_metadata where TABLE_NAME='EMPTY_LAYER'")


if __name__ == '__main__':
unittest.main()

0 comments on commit ca637cf

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