Skip to content
Permalink
Browse files

Make sure QgsDataSourceUri remembers the schema

This is useful for partial URI storage (schema level)
  • Loading branch information
elpaso committed Mar 11, 2020
1 parent 2e992c0 commit c4a017b706a7c114ad0f742b7c15f7b5ccaaefed
Showing with 54 additions and 5 deletions.
  1. +4 −0 src/core/qgsdatasourceuri.cpp
  2. +50 −5 tests/src/core/testqgsdatasourceuri.cpp
@@ -586,6 +586,10 @@ QString QgsDataSourceUri::uri( bool expandAuthConfig ) const
.arg( quotedTablename(),
mGeometryColumn.isNull() ? QString() : QStringLiteral( " (%1)" ).arg( columnName ) );
}
else if ( !mSchema.isEmpty() )
{
uri += QStringLiteral( " schema='%1'" ).arg( escape( mSchema ) );
}

if ( !mSql.isEmpty() )
{
@@ -76,8 +76,30 @@ void TestQgsDataSourceUri::checkparser_data()
;

QTest::newRow( "pgrast" )
<< "PG: dbname=mydb host=myhost user=myname password=mypasswd port=5432 mode=2 schema=public column=geom table=mytable"
<< "mytable" // table
<< R"(PG: dbname='qgis_tests' host=localhost port=5432 user='myname' sslmode=disable estimatedmetadata=true srid=3067 table="public"."basic_map_tiled" (rast))"
<< "basic_map_tiled" // table
<< "rast" // geometrycolumn
<< "" // key
<< true // estimatedmetadata
<< "3067" // srid
<< QgsWkbTypes::Unknown // type
<< false // selectatid
<< "" // service
<< "myname" // user
<< "" // password
<< "qgis_tests" // dbname
<< "localhost" // host
<< "5432" // port
<< "" // driver
<< QgsDataSourceUri::SslDisable // sslmode
<< "" // sql
<< "" // myparam
<< "public" // schema
;

QTest::newRow( "pg_notable" )
<< "PG: dbname=mydb host=myhost user=myname password=mypasswd port=5432 mode=2 schema=myschema "
<< "" // table
<< "" // geometrycolumn
<< "" // key
<< false // estimatedmetadata
@@ -94,9 +116,32 @@ void TestQgsDataSourceUri::checkparser_data()
<< QgsDataSourceUri::SslPrefer // sslmode
<< "" // sql
<< "" // myparam
<< "public"
<< "public" // schema
;

QTest::newRow( "pg_notable_quoted" )
<< "dbname='mydb' host='myhost' user='myname' password='mypasswd' port='5432' mode='2' schema=myschema"
<< "" // table
<< "" // geometrycolumn
<< "" // key
<< false // estimatedmetadata
<< "" // srid
<< QgsWkbTypes::Unknown // type
<< false // selectatid
<< "" // service
<< "myname" // user
<< "mypasswd" // password
<< "mydb" // dbname
<< "myhost" // host
<< "5432" // port
<< "" // driver
<< QgsDataSourceUri::SslPrefer // sslmode
<< "" // sql
<< "" // myparam
<< "public" // schema
;



QTest::newRow( "pgmlsz" )
<< "PG: dbname=mydb host=myhost user=myname password=mypasswd port=5432 mode=2 schema=public column=geom table=mytable type=MultiLineStringZ"
@@ -117,7 +162,7 @@ void TestQgsDataSourceUri::checkparser_data()
<< QgsDataSourceUri::SslPrefer // sslmode
<< "" // sql
<< "" // myparam
<< "public"
<< "public" // schema
;

QTest::newRow( "DB2" )
@@ -139,7 +184,7 @@ void TestQgsDataSourceUri::checkparser_data()
<< QgsDataSourceUri::SslPrefer // sslmode
<< "" // sql
<< "myvalue" // myparam
<< "TEST"
<< "TEST" // schema
;
}

0 comments on commit c4a017b

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