Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Use isValid instead of isNull and add a test for gpkg
- Loading branch information
Showing
with
3 additions
and
1 deletion.
-
+1
−1
src/app/qgisapp.cpp
-
+2
−0
tests/src/providers/testqgsogrprovider.cpp
|
@@ -4611,7 +4611,7 @@ bool QgisApp::addVectorLayers( const QStringList &layerQStringList, const QStrin |
|
|
// Try to extract the database name and use it as base name |
|
|
// sublayers names (if any) will be appended to the layer name |
|
|
auto parts( QgsProviderRegistry::instance()->decodeUri( QStringLiteral( "ogr" ), src ) ); |
|
|
if ( ! parts.value( QStringLiteral( "layerName" ) ).isNull() ) |
|
|
if ( parts.value( QStringLiteral( "layerName" ) ).isValid() ) |
|
|
baseName = parts.value( QStringLiteral( "layerName" ) ).toString(); |
|
|
else |
|
|
baseName = src; |
|
|
|
@@ -126,6 +126,8 @@ void TestQgsOgrProvider::decodeUri() |
|
|
QCOMPARE( parts.value( QStringLiteral( "layerName" ) ).toString(), QString( "database_name" ) ); |
|
|
parts = QgsProviderRegistry::instance()->decodeUri( QStringLiteral( "ogr" ), QStringLiteral( "MYSQL:westholland,user=root,password=psv9570,port=3306,tables=bedrijven" ) ); |
|
|
QCOMPARE( parts.value( QStringLiteral( "layerName" ) ).toString(), QString( "westholland" ) ); |
|
|
parts = QgsProviderRegistry::instance()->decodeUri( QStringLiteral( "ogr" ), QStringLiteral( "/path/to/a/geopackage.gpkg|layername=a_layer" ) ); |
|
|
QCOMPARE( parts.value( QStringLiteral( "layerName" ) ).toString(), QString( "a_layer" ) ); |
|
|
} |
|
|
|
|
|
|
|
|