Skip to content
Permalink
Browse files

Use isValid instead of isNull and add a test for gpkg

  • Loading branch information
elpaso committed Nov 22, 2018
1 parent 84eed01 commit 7094ddf18efe0b1b528f8e962bc70fe99881c34b
Showing with 3 additions and 1 deletion.
  1. +1 −1 src/app/qgisapp.cpp
  2. +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" ) );
}


0 comments on commit 7094ddf

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