Skip to content

Commit 756991b

Browse files
committed
[Spatialite] Remove t_table_catalog WHERE clause when searcing for layer styles in db
This sanity check is unnecessary and breaks styling if the sqlite file is moved or renamed. The t_table_catalog column is kept for backwards compatibility.
1 parent 6851c34 commit 756991b

File tree

1 file changed

+19
-30
lines changed

1 file changed

+19
-30
lines changed

src/providers/spatialite/qgsspatialiteprovider.cpp

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5330,7 +5330,7 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
53305330
") VALUES ("
53315331
"%1,%2,%3,%4,%5,%6,%7,%8,%9,%10%12"
53325332
")" )
5333-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
5333+
.arg( QgsSpatiaLiteProvider::quotedValue( QString() ) )
53345334
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
53355335
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
53365336
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) )
@@ -5345,12 +5345,10 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
53455345

53465346
QString checkQuery = QString( "SELECT styleName"
53475347
" FROM layer_styles"
5348-
" WHERE f_table_catalog=%1"
5349-
" AND f_table_schema=%2"
5350-
" AND f_table_name=%3"
5351-
" AND f_geometry_column=%4"
5352-
" AND styleName=%5" )
5353-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
5348+
" WHERE f_table_schema=%1"
5349+
" AND f_table_name=%2"
5350+
" AND f_geometry_column=%3"
5351+
" AND styleName=%4" )
53545352
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
53555353
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
53565354
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) )
@@ -5384,17 +5382,15 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
53845382
",styleSLD=%3"
53855383
",description=%4"
53865384
",owner=%5"
5387-
" WHERE f_table_catalog=%6"
5388-
" AND f_table_schema=%7"
5389-
" AND f_table_name=%8"
5390-
" AND f_geometry_column=%9"
5391-
" AND styleName=%10" )
5385+
" WHERE f_table_schema=%6"
5386+
" AND f_table_name=%7"
5387+
" AND f_geometry_column=%8"
5388+
" AND styleName=%9" )
53925389
.arg( useAsDefault ? "1" : "0" )
53935390
.arg( QgsSpatiaLiteProvider::quotedValue( qmlStyle ) )
53945391
.arg( QgsSpatiaLiteProvider::quotedValue( sldStyle ) )
53955392
.arg( QgsSpatiaLiteProvider::quotedValue( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) )
53965393
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.username() ) )
5397-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
53985394
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
53995395
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
54005396
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) )
@@ -5405,11 +5401,9 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
54055401
{
54065402
QString removeDefaultSql = QString( "UPDATE layer_styles"
54075403
" SET useAsDefault=0"
5408-
" WHERE f_table_catalog=%1"
5409-
" AND f_table_schema=%2"
5410-
" AND f_table_name=%3"
5411-
" AND f_geometry_column=%4" )
5412-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
5404+
" WHERE f_table_schema=%1"
5405+
" AND f_table_name=%2"
5406+
" AND f_geometry_column=%3" )
54135407
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
54145408
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
54155409
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) );
@@ -5460,13 +5454,11 @@ QGISEXTERN QString loadStyle( const QString& uri, QString& errCause )
54605454

54615455
QString selectQmlQuery = QString( "SELECT styleQML"
54625456
" FROM layer_styles"
5463-
" WHERE f_table_catalog=%1"
5464-
" AND f_table_schema=%2"
5465-
" AND f_table_name=%3"
5466-
" AND f_geometry_column=%4"
5457+
" WHERE f_table_schema=%1"
5458+
" AND f_table_name=%2"
5459+
" AND f_geometry_column=%3"
54675460
" ORDER BY CASE WHEN useAsDefault THEN 1 ELSE 2 END"
54685461
",update_time DESC LIMIT 1" )
5469-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
54705462
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
54715463
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
54725464
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) );
@@ -5543,11 +5535,9 @@ QGISEXTERN int listStyles( const QString &uri, QStringList &ids, QStringList &na
55435535
// get them
55445536
QString selectRelatedQuery = QString( "SELECT id,styleName,description"
55455537
" FROM layer_styles"
5546-
" WHERE f_table_catalog=%1"
5547-
" AND f_table_schema=%2"
5548-
" AND f_table_name=%3"
5549-
" AND f_geometry_column=%4" )
5550-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
5538+
" WHERE f_table_schema=%1"
5539+
" AND f_table_name=%2"
5540+
" AND f_geometry_column=%3" )
55515541
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
55525542
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
55535543
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) );
@@ -5572,9 +5562,8 @@ QGISEXTERN int listStyles( const QString &uri, QStringList &ids, QStringList &na
55725562

55735563
QString selectOthersQuery = QString( "SELECT id,styleName,description"
55745564
" FROM layer_styles"
5575-
" WHERE NOT (f_table_catalog=%1 AND f_table_schema=%2 AND f_table_name=%3 AND f_geometry_column=%4)"
5565+
" WHERE NOT (f_table_schema=%1 AND f_table_name=%2 AND f_geometry_column=%3)"
55765566
" ORDER BY update_time DESC" )
5577-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
55785567
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
55795568
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
55805569
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) );

0 commit comments

Comments
 (0)