Skip to content

Commit

Permalink
Merge pull request #54806 from nyalldawson/fix_53736
Browse files Browse the repository at this point in the history
Handle sql='' or sql="" as empty sql strings instead of '' / "" literals
  • Loading branch information
elpaso committed Oct 4, 2023
2 parents 7ab5c5b + 76360da commit 0c69978
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/qgsdatasourceuri.cpp
Expand Up @@ -71,6 +71,12 @@ QgsDataSourceUri::QgsDataSourceUri( const QString &u )
// rest of line is a sql where clause
skipBlanks( uri, i );
mSql = uri.mid( i );

// handle empty sql specified by a empty '' or "" encapsulated value
// possibly we should be calling getValue here, but there's a very high risk of regressions
// if we change that now...
if ( mSql == QLatin1String( "''" ) || mSql == QLatin1String( "\"\"" ) )
mSql.clear();
break;
}
else
Expand Down
69 changes: 69 additions & 0 deletions tests/src/core/testqgsdatasourceuri.cpp
Expand Up @@ -201,6 +201,75 @@ void TestQgsDataSourceUri::checkparser_data()
<< "" // myparam
<< "public" // schema
;

QTest::newRow( "arcgis rest sql" )
<< "crs='EPSG:2154' filter='' url='https://carto.isogeo.net/server/rest/services/scan_services_1/EMS_EFS_WMS_WFS/FeatureServer/2' table='' sql=abc='def'"
<< "" // table
<< "" // geometrycolumn
<< "" // key
<< false // estimatedmetadata
<< "" // srid
<< Qgis::WkbType::Unknown // type
<< false // selectatid
<< "" // service
<< "" // user
<< "" // password
<< "" // authcfg
<< "" // dbname
<< "" // host
<< "" // port
<< "" // driver
<< QgsDataSourceUri::SslPrefer // sslmode
<< "abc='def'" // sql
<< "" // myparam
<< "public" // schema
;

QTest::newRow( "arcgis rest empty sql" )
<< "crs='EPSG:2154' filter='' url='https://carto.isogeo.net/server/rest/services/scan_services_1/EMS_EFS_WMS_WFS/FeatureServer/2' table='' sql=''"
<< "" // table
<< "" // geometrycolumn
<< "" // key
<< false // estimatedmetadata
<< "" // srid
<< Qgis::WkbType::Unknown // type
<< false // selectatid
<< "" // service
<< "" // user
<< "" // password
<< "" // authcfg
<< "" // dbname
<< "" // host
<< "" // port
<< "" // driver
<< QgsDataSourceUri::SslPrefer // sslmode
<< "" // sql
<< "" // myparam
<< "public" // schema
;

QTest::newRow( "arcgis rest empty sql 2" )
<< "crs='EPSG:2154' filter='' url='https://carto.isogeo.net/server/rest/services/scan_services_1/EMS_EFS_WMS_WFS/FeatureServer/2' table='' sql=\"\""
<< "" // table
<< "" // geometrycolumn
<< "" // key
<< false // estimatedmetadata
<< "" // srid
<< Qgis::WkbType::Unknown // type
<< false // selectatid
<< "" // service
<< "" // user
<< "" // password
<< "" // authcfg
<< "" // dbname
<< "" // host
<< "" // port
<< "" // driver
<< QgsDataSourceUri::SslPrefer // sslmode
<< "" // sql
<< "" // myparam
<< "public" // schema
;
}

void TestQgsDataSourceUri::checkparser()
Expand Down

0 comments on commit 0c69978

Please sign in to comment.