mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-06 00:05:02 -05:00
Fix loading style for non-spatial tables in Postgres+SpatiaLite (fixes #19589)
OGR is not affected by the bug. Oracle and MS SQL are most likely affected, but I don't have them here to test.
This commit is contained in:
parent
5508ea036e
commit
bb0c629355
@ -4819,18 +4819,28 @@ QGISEXTERN QString loadStyle( const QString &uri, QString &errCause )
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString geomColumnExpr;
|
||||
if ( dsUri.geometryColumn().isEmpty() )
|
||||
{
|
||||
geomColumnExpr = QStringLiteral( "IS NULL" );
|
||||
}
|
||||
else
|
||||
{
|
||||
geomColumnExpr = QStringLiteral( "=" ) + QgsPostgresConn::quotedValue( dsUri.geometryColumn() );
|
||||
}
|
||||
|
||||
QString selectQmlQuery = QString( "SELECT styleQML"
|
||||
" FROM layer_styles"
|
||||
" WHERE f_table_catalog=%1"
|
||||
" AND f_table_schema=%2"
|
||||
" AND f_table_name=%3"
|
||||
" AND f_geometry_column=%4"
|
||||
" AND f_geometry_column %4"
|
||||
" ORDER BY CASE WHEN useAsDefault THEN 1 ELSE 2 END"
|
||||
",update_time DESC LIMIT 1" )
|
||||
.arg( QgsPostgresConn::quotedValue( dsUri.database() ) )
|
||||
.arg( QgsPostgresConn::quotedValue( dsUri.schema() ) )
|
||||
.arg( QgsPostgresConn::quotedValue( dsUri.table() ) )
|
||||
.arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) );
|
||||
.arg( geomColumnExpr );
|
||||
|
||||
QgsPostgresResult result( conn->PQexec( selectQmlQuery ) );
|
||||
|
||||
|
@ -5814,16 +5814,26 @@ QGISEXTERN QString loadStyle( const QString &uri, QString &errCause )
|
||||
|
||||
sqlite3 *sqliteHandle = handle->handle();
|
||||
|
||||
QString geomColumnExpr;
|
||||
if ( dsUri.geometryColumn().isEmpty() )
|
||||
{
|
||||
geomColumnExpr = QStringLiteral( "IS NULL" );
|
||||
}
|
||||
else
|
||||
{
|
||||
geomColumnExpr = QStringLiteral( "=" ) + QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() );
|
||||
}
|
||||
|
||||
QString selectQmlQuery = QString( "SELECT styleQML"
|
||||
" FROM layer_styles"
|
||||
" WHERE f_table_schema %1"
|
||||
" AND f_table_name=%2"
|
||||
" AND f_geometry_column=%3"
|
||||
" AND f_geometry_column %3"
|
||||
" ORDER BY CASE WHEN useAsDefault THEN 1 ELSE 2 END"
|
||||
",update_time DESC LIMIT 1" )
|
||||
.arg( QgsSpatiaLiteProvider::tableSchemaCondition( dsUri ) )
|
||||
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
|
||||
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) );
|
||||
.arg( geomColumnExpr );
|
||||
|
||||
char **results = nullptr;
|
||||
int rows;
|
||||
|
Loading…
x
Reference in New Issue
Block a user