Skip to content

Commit

Permalink
Merge pull request #52822 from qgis/backport-52676-to-queued_ltr_back…
Browse files Browse the repository at this point in the history
…ports

[Backport queued_ltr_backports] [Oracle] Fix srid when creating a vector layer from table
  • Loading branch information
troopa81 committed Apr 22, 2023
2 parents 5c5bb2d + 329d83c commit c944371
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/providers/oracle/qgsoracleproviderconnection.cpp
Expand Up @@ -210,8 +210,7 @@ QgsVectorLayer *QgsOracleProviderConnection::createSqlVectorLayer( const QgsAbst
const int type { row[ 0 ].toInt( &ok ) };
if ( ok )
{
const int srid { row[ 0 ].toInt( &ok ) };

const int srid { row[ 1 ].toInt( &ok ) };
if ( ok )
{

Expand Down
7 changes: 7 additions & 0 deletions tests/src/python/test_qgsproviderconnection_base.py
Expand Up @@ -61,6 +61,7 @@ class TestPyQgsProviderConnectionBase():
# Provider test cases can define a schema and table name for SQL query layers test
sqlVectorLayerSchema = None # string, empty string for schema-less DBs (SQLite)
sqlVectorLayerTable = None # string
sqlVectorLayerCrs = None # string

@classmethod
def setUpClass(cls):
Expand Down Expand Up @@ -544,6 +545,11 @@ def testCreateSqlVectorLayer(self):
print(f"FIXME: {self.providerKey} data provider test case does not define self.sqlVectorLayerTable for query layers test!")
return

crs = getattr(self, 'sqlVectorLayerCrs', None)
if crs is None:
print(f"FIXME: {self.providerKey} data provider test case does not define self.sqlVectorLayerCrs for query layers test!")
return

sql_layer_capabilities = conn.sqlLayerDefinitionCapabilities()

# Try a simple select first
Expand All @@ -566,6 +572,7 @@ def testCreateSqlVectorLayer(self):
self.assertTrue(vl.isValid())
self.assertTrue(vl.isSpatial())
self.assertEqual(vl.name(), options.layerName)
self.assertEqual(vl.sourceCrs().authid(), crs)

# Test that a database connection can be retrieved from an existing layer
vlconn = QgsMapLayerUtils.databaseConnection(vl)
Expand Down
1 change: 1 addition & 0 deletions tests/src/python/test_qgsproviderconnection_ogr_gpkg.py
Expand Up @@ -65,6 +65,7 @@ class TestPyQgsProviderConnectionGpkg(unittest.TestCase, TestPyQgsProviderConnec
# Provider test cases can define a schema and table name for SQL query layers test
sqlVectorLayerSchema = ''
sqlVectorLayerTable = 'cdb_lines'
sqlVectorLayerCrs = 'EPSG:25832'

@classmethod
def setUpClass(cls):
Expand Down
1 change: 1 addition & 0 deletions tests/src/python/test_qgsproviderconnection_oracle.py
Expand Up @@ -49,6 +49,7 @@ class TestPyQgsProviderConnectionOracle(unittest.TestCase, TestPyQgsProviderConn
# Provider test cases can define a schema and table name for SQL query layers test
sqlVectorLayerSchema = 'QGIS'
sqlVectorLayerTable = 'SOME_DATA'
sqlVectorLayerCrs = 'EPSG:4326'

def execSQLCommand(self, sql, ignore_errors=False):
self.assertTrue(self.conn)
Expand Down
1 change: 1 addition & 0 deletions tests/src/python/test_qgsproviderconnection_postgres.py
Expand Up @@ -44,6 +44,7 @@ class TestPyQgsProviderConnectionPostgres(unittest.TestCase, TestPyQgsProviderCo
# Provider test cases can define a schema and table name for SQL query layers test
sqlVectorLayerSchema = 'qgis_test'
sqlVectorLayerTable = 'someData'
sqlVectorLayerCrs = 'EPSG:4326'

@classmethod
def setUpClass(cls):
Expand Down
1 change: 1 addition & 0 deletions tests/src/python/test_qgsproviderconnection_spatialite.py
Expand Up @@ -56,6 +56,7 @@ class TestPyQgsProviderConnectionSpatialite(unittest.TestCase, TestPyQgsProvider
# Provider test cases can define a schema and table name for SQL query layers test
sqlVectorLayerSchema = ''
sqlVectorLayerTable = 'cdb_lines'
sqlVectorLayerCrs = 'EPSG:25832'

@classmethod
def setUpClass(cls):
Expand Down

0 comments on commit c944371

Please sign in to comment.