Skip to content

Commit 3b118a2

Browse files
authored
Merge pull request #3339 from manisandro/spatialite_ftablecatalog
[Spatialite] Only store database filename in f_table_catalog, not entire path
2 parents f7e7ecf + 2b8b8ae commit 3b118a2

File tree

1 file changed

+19
-30
lines changed

1 file changed

+19
-30
lines changed

src/providers/spatialite/qgsspatialiteprovider.cpp

+19-30
Original file line numberDiff line numberDiff line change
@@ -5333,7 +5333,7 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
53335333
") VALUES ("
53345334
"%1,%2,%3,%4,%5,%6,%7,%8,%9,%10%12"
53355335
")" )
5336-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
5336+
.arg( QgsSpatiaLiteProvider::quotedValue( QString() ) )
53375337
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
53385338
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
53395339
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) )
@@ -5348,12 +5348,10 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
53485348

53495349
QString checkQuery = QString( "SELECT styleName"
53505350
" FROM layer_styles"
5351-
" WHERE f_table_catalog=%1"
5352-
" AND f_table_schema=%2"
5353-
" AND f_table_name=%3"
5354-
" AND f_geometry_column=%4"
5355-
" AND styleName=%5" )
5356-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
5351+
" WHERE f_table_schema=%1"
5352+
" AND f_table_name=%2"
5353+
" AND f_geometry_column=%3"
5354+
" AND styleName=%4" )
53575355
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
53585356
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
53595357
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) )
@@ -5387,17 +5385,15 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
53875385
",styleSLD=%3"
53885386
",description=%4"
53895387
",owner=%5"
5390-
" WHERE f_table_catalog=%6"
5391-
" AND f_table_schema=%7"
5392-
" AND f_table_name=%8"
5393-
" AND f_geometry_column=%9"
5394-
" AND styleName=%10" )
5388+
" WHERE f_table_schema=%6"
5389+
" AND f_table_name=%7"
5390+
" AND f_geometry_column=%8"
5391+
" AND styleName=%9" )
53955392
.arg( useAsDefault ? "1" : "0" )
53965393
.arg( QgsSpatiaLiteProvider::quotedValue( qmlStyle ) )
53975394
.arg( QgsSpatiaLiteProvider::quotedValue( sldStyle ) )
53985395
.arg( QgsSpatiaLiteProvider::quotedValue( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) )
53995396
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.username() ) )
5400-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
54015397
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
54025398
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
54035399
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) )
@@ -5408,11 +5404,9 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
54085404
{
54095405
QString removeDefaultSql = QString( "UPDATE layer_styles"
54105406
" SET useAsDefault=0"
5411-
" WHERE f_table_catalog=%1"
5412-
" AND f_table_schema=%2"
5413-
" AND f_table_name=%3"
5414-
" AND f_geometry_column=%4" )
5415-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
5407+
" WHERE f_table_schema=%1"
5408+
" AND f_table_name=%2"
5409+
" AND f_geometry_column=%3" )
54165410
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
54175411
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
54185412
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) );
@@ -5455,13 +5449,11 @@ QGISEXTERN QString loadStyle( const QString& uri, QString& errCause )
54555449

54565450
QString selectQmlQuery = QString( "SELECT styleQML"
54575451
" FROM layer_styles"
5458-
" WHERE f_table_catalog=%1"
5459-
" AND f_table_schema=%2"
5460-
" AND f_table_name=%3"
5461-
" AND f_geometry_column=%4"
5452+
" WHERE f_table_schema=%1"
5453+
" AND f_table_name=%2"
5454+
" AND f_geometry_column=%3"
54625455
" ORDER BY CASE WHEN useAsDefault THEN 1 ELSE 2 END"
54635456
",update_time DESC LIMIT 1" )
5464-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
54655457
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
54665458
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
54675459
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) );
@@ -5538,11 +5530,9 @@ QGISEXTERN int listStyles( const QString &uri, QStringList &ids, QStringList &na
55385530
// get them
55395531
QString selectRelatedQuery = QString( "SELECT id,styleName,description"
55405532
" FROM layer_styles"
5541-
" WHERE f_table_catalog=%1"
5542-
" AND f_table_schema=%2"
5543-
" AND f_table_name=%3"
5544-
" AND f_geometry_column=%4" )
5545-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
5533+
" WHERE f_table_schema=%1"
5534+
" AND f_table_name=%2"
5535+
" AND f_geometry_column=%3" )
55465536
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
55475537
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
55485538
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) );
@@ -5567,9 +5557,8 @@ QGISEXTERN int listStyles( const QString &uri, QStringList &ids, QStringList &na
55675557

55685558
QString selectOthersQuery = QString( "SELECT id,styleName,description"
55695559
" FROM layer_styles"
5570-
" WHERE NOT (f_table_catalog=%1 AND f_table_schema=%2 AND f_table_name=%3 AND f_geometry_column=%4)"
5560+
" WHERE NOT (f_table_schema=%1 AND f_table_name=%2 AND f_geometry_column=%3)"
55715561
" ORDER BY update_time DESC" )
5572-
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.database() ) )
55735562
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.schema() ) )
55745563
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
55755564
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) );

0 commit comments

Comments
 (0)