mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Fix #37338
This commit is contained in:
parent
088885645c
commit
5c3dff6f6b
@ -5082,7 +5082,7 @@ bool QgsPostgresProviderMetadata::saveStyle( const QString &uri, const QString &
|
|||||||
" AND f_table_schema=%2"
|
" AND f_table_schema=%2"
|
||||||
" AND f_table_name=%3"
|
" AND f_table_name=%3"
|
||||||
" AND f_geometry_column=%4"
|
" AND f_geometry_column=%4"
|
||||||
" AND type=%5"
|
" AND (type=%5 OR type IS NULL)"
|
||||||
" AND styleName=%6" )
|
" AND styleName=%6" )
|
||||||
.arg( QgsPostgresConn::quotedValue( dsUri.database() ) )
|
.arg( QgsPostgresConn::quotedValue( dsUri.database() ) )
|
||||||
.arg( QgsPostgresConn::quotedValue( dsUri.schema() ) )
|
.arg( QgsPostgresConn::quotedValue( dsUri.schema() ) )
|
||||||
@ -5110,12 +5110,13 @@ bool QgsPostgresProviderMetadata::saveStyle( const QString &uri, const QString &
|
|||||||
",styleSLD=XMLPARSE(DOCUMENT %13)"
|
",styleSLD=XMLPARSE(DOCUMENT %13)"
|
||||||
",description=%4"
|
",description=%4"
|
||||||
",owner=%5"
|
",owner=%5"
|
||||||
|
",type=%2"
|
||||||
" WHERE f_table_catalog=%6"
|
" WHERE f_table_catalog=%6"
|
||||||
" AND f_table_schema=%7"
|
" AND f_table_schema=%7"
|
||||||
" AND f_table_name=%8"
|
" AND f_table_name=%8"
|
||||||
" AND f_geometry_column=%9"
|
" AND f_geometry_column=%9"
|
||||||
" AND styleName=%10"
|
" AND styleName=%10"
|
||||||
" AND type=%2" )
|
" AND (type=%2 OR type IS NULL)" )
|
||||||
.arg( useAsDefault ? "true" : "false" )
|
.arg( useAsDefault ? "true" : "false" )
|
||||||
.arg( wkbTypeString )
|
.arg( wkbTypeString )
|
||||||
.arg( QgsPostgresConn::quotedValue( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) )
|
.arg( QgsPostgresConn::quotedValue( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) )
|
||||||
@ -5138,7 +5139,7 @@ bool QgsPostgresProviderMetadata::saveStyle( const QString &uri, const QString &
|
|||||||
" AND f_table_schema=%2"
|
" AND f_table_schema=%2"
|
||||||
" AND f_table_name=%3"
|
" AND f_table_name=%3"
|
||||||
" AND f_geometry_column=%4"
|
" AND f_geometry_column=%4"
|
||||||
" AND type=%5" )
|
" AND (type=%5 OR type IS NULL)" )
|
||||||
.arg( QgsPostgresConn::quotedValue( dsUri.database() ) )
|
.arg( QgsPostgresConn::quotedValue( dsUri.database() ) )
|
||||||
.arg( QgsPostgresConn::quotedValue( dsUri.schema() ) )
|
.arg( QgsPostgresConn::quotedValue( dsUri.schema() ) )
|
||||||
.arg( QgsPostgresConn::quotedValue( dsUri.table() ) )
|
.arg( QgsPostgresConn::quotedValue( dsUri.table() ) )
|
||||||
@ -5163,6 +5164,7 @@ bool QgsPostgresProviderMetadata::saveStyle( const QString &uri, const QString &
|
|||||||
QString QgsPostgresProviderMetadata::loadStyle( const QString &uri, QString &errCause )
|
QString QgsPostgresProviderMetadata::loadStyle( const QString &uri, QString &errCause )
|
||||||
{
|
{
|
||||||
QgsDataSourceUri dsUri( uri );
|
QgsDataSourceUri dsUri( uri );
|
||||||
|
QString selectQmlQuery;
|
||||||
|
|
||||||
QgsPostgresConn *conn = QgsPostgresConn::connectDb( dsUri.connectionInfo( false ), false );
|
QgsPostgresConn *conn = QgsPostgresConn::connectDb( dsUri.connectionInfo( false ), false );
|
||||||
if ( !conn )
|
if ( !conn )
|
||||||
@ -5194,20 +5196,39 @@ QString QgsPostgresProviderMetadata::loadStyle( const QString &uri, QString &err
|
|||||||
|
|
||||||
QString wkbTypeString = QgsPostgresConn::quotedValue( QgsWkbTypes::geometryDisplayString( QgsWkbTypes::geometryType( dsUri.wkbType() ) ) );
|
QString wkbTypeString = QgsPostgresConn::quotedValue( QgsWkbTypes::geometryDisplayString( QgsWkbTypes::geometryType( dsUri.wkbType() ) ) );
|
||||||
|
|
||||||
QString selectQmlQuery = QString( "SELECT styleQML"
|
// support layer_styles without type column < 3.14
|
||||||
" FROM layer_styles"
|
if ( !columnExists( *conn, QStringLiteral( "layer_styles" ), QStringLiteral( "type" ) ) )
|
||||||
" WHERE f_table_catalog=%1"
|
{
|
||||||
" AND f_table_schema=%2"
|
selectQmlQuery = QString( "SELECT styleQML"
|
||||||
" AND f_table_name=%3"
|
" FROM layer_styles"
|
||||||
" AND f_geometry_column %4"
|
" WHERE f_table_catalog=%1"
|
||||||
" AND type=%5"
|
" AND f_table_schema=%2"
|
||||||
" ORDER BY CASE WHEN useAsDefault THEN 1 ELSE 2 END"
|
" AND f_table_name=%3"
|
||||||
",update_time DESC LIMIT 1" )
|
" AND f_geometry_column %4"
|
||||||
.arg( QgsPostgresConn::quotedValue( dsUri.database() ) )
|
" ORDER BY CASE WHEN useAsDefault THEN 1 ELSE 2 END"
|
||||||
.arg( QgsPostgresConn::quotedValue( dsUri.schema() ) )
|
",update_time DESC LIMIT 1" )
|
||||||
.arg( QgsPostgresConn::quotedValue( dsUri.table() ) )
|
.arg( QgsPostgresConn::quotedValue( dsUri.database() ) )
|
||||||
.arg( geomColumnExpr )
|
.arg( QgsPostgresConn::quotedValue( dsUri.schema() ) )
|
||||||
.arg( wkbTypeString );
|
.arg( QgsPostgresConn::quotedValue( dsUri.table() ) )
|
||||||
|
.arg( geomColumnExpr );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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 (type=%5 OR type IS NULL)"
|
||||||
|
" 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( geomColumnExpr )
|
||||||
|
.arg( wkbTypeString );
|
||||||
|
}
|
||||||
|
|
||||||
QgsPostgresResult result( conn->PQexec( selectQmlQuery ) );
|
QgsPostgresResult result( conn->PQexec( selectQmlQuery ) );
|
||||||
|
|
||||||
@ -5242,7 +5263,7 @@ int QgsPostgresProviderMetadata::listStyles( const QString &uri, QStringList &id
|
|||||||
" AND f_table_schema=%2"
|
" AND f_table_schema=%2"
|
||||||
" AND f_table_name=%3"
|
" AND f_table_name=%3"
|
||||||
" AND f_geometry_column=%4"
|
" AND f_geometry_column=%4"
|
||||||
" AND type=%5"
|
" AND (type=%5 OR type IS NULL)"
|
||||||
" ORDER BY useasdefault DESC, update_time DESC" )
|
" ORDER BY useasdefault DESC, update_time DESC" )
|
||||||
.arg( QgsPostgresConn::quotedValue( dsUri.database() ) )
|
.arg( QgsPostgresConn::quotedValue( dsUri.database() ) )
|
||||||
.arg( QgsPostgresConn::quotedValue( dsUri.schema() ) )
|
.arg( QgsPostgresConn::quotedValue( dsUri.schema() ) )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user