Skip to content

Commit 2b8b8ae

Browse files
committedAug 3, 2016
[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 ee09131 commit 2b8b8ae

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
@@ -5335,7 +5335,7 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
53355335
") VALUES ("
53365336
"%1,%2,%3,%4,%5,%6,%7,%8,%9,%10%12"
53375337
")" )
5338-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
5338+
.arg( QgsSpatiaLiteProvider::quotedValue( QString() ) )
53395339
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
53405340
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
53415341
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) )
@@ -5350,12 +5350,10 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
53505350

53515351
QString checkQuery = QString( "SELECT styleName"
53525352
" FROM layer_styles"
5353-
" WHERE f_table_catalog=%1"
5354-
" AND f_table_schema=%2"
5355-
" AND f_table_name=%3"
5356-
" AND f_geometry_column=%4"
5357-
" AND styleName=%5" )
5358-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
5353+
" WHERE f_table_schema=%1"
5354+
" AND f_table_name=%2"
5355+
" AND f_geometry_column=%3"
5356+
" AND styleName=%4" )
53595357
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
53605358
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
53615359
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) )
@@ -5389,17 +5387,15 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
53895387
",styleSLD=%3"
53905388
",description=%4"
53915389
",owner=%5"
5392-
" WHERE f_table_catalog=%6"
5393-
" AND f_table_schema=%7"
5394-
" AND f_table_name=%8"
5395-
" AND f_geometry_column=%9"
5396-
" AND styleName=%10" )
5390+
" WHERE f_table_schema=%6"
5391+
" AND f_table_name=%7"
5392+
" AND f_geometry_column=%8"
5393+
" AND styleName=%9" )
53975394
.arg( useAsDefault ? "1" : "0" )
53985395
.arg( QgsSpatiaLiteProvider::quotedValue( qmlStyle ) )
53995396
.arg( QgsSpatiaLiteProvider::quotedValue( sldStyle ) )
54005397
.arg( QgsSpatiaLiteProvider::quotedValue( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) )
54015398
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.username() ) )
5402-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
54035399
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
54045400
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
54055401
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) )
@@ -5410,11 +5406,9 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
54105406
{
54115407
QString removeDefaultSql = QString( "UPDATE layer_styles"
54125408
" SET useAsDefault=0"
5413-
" WHERE f_table_catalog=%1"
5414-
" AND f_table_schema=%2"
5415-
" AND f_table_name=%3"
5416-
" AND f_geometry_column=%4" )
5417-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
5409+
" WHERE f_table_schema=%1"
5410+
" AND f_table_name=%2"
5411+
" AND f_geometry_column=%3" )
54185412
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
54195413
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
54205414
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) );
@@ -5457,13 +5451,11 @@ QGISEXTERN QString loadStyle( const QString& uri, QString& errCause )
54575451

54585452
QString selectQmlQuery = QString( "SELECT styleQML"
54595453
" FROM layer_styles"
5460-
" WHERE f_table_catalog=%1"
5461-
" AND f_table_schema=%2"
5462-
" AND f_table_name=%3"
5463-
" AND f_geometry_column=%4"
5454+
" WHERE f_table_schema=%1"
5455+
" AND f_table_name=%2"
5456+
" AND f_geometry_column=%3"
54645457
" ORDER BY CASE WHEN useAsDefault THEN 1 ELSE 2 END"
54655458
",update_time DESC LIMIT 1" )
5466-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
54675459
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
54685460
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
54695461
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) );
@@ -5540,11 +5532,9 @@ QGISEXTERN int listStyles( const QString &uri, QStringList &ids, QStringList &na
55405532
// get them
55415533
QString selectRelatedQuery = QString( "SELECT id,styleName,description"
55425534
" FROM layer_styles"
5543-
" WHERE f_table_catalog=%1"
5544-
" AND f_table_schema=%2"
5545-
" AND f_table_name=%3"
5546-
" AND f_geometry_column=%4" )
5547-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
5535+
" WHERE f_table_schema=%1"
5536+
" AND f_table_name=%2"
5537+
" AND f_geometry_column=%3" )
55485538
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
55495539
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
55505540
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) );
@@ -5569,9 +5559,8 @@ QGISEXTERN int listStyles( const QString &uri, QStringList &ids, QStringList &na
55695559

55705560
QString selectOthersQuery = QString( "SELECT id,styleName,description"
55715561
" FROM layer_styles"
5572-
" WHERE NOT (f_table_catalog=%1 AND f_table_schema=%2 AND f_table_name=%3 AND f_geometry_column=%4)"
5562+
" WHERE NOT (f_table_schema=%1 AND f_table_name=%2 AND f_geometry_column=%3)"
55735563
" ORDER BY update_time DESC" )
5574-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
55755564
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
55765565
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
55775566
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) );

0 commit comments

Comments
 (0)
Please sign in to comment.