From 28e837ab4801b0d7dbb1996a482d6cf5e10105bd Mon Sep 17 00:00:00 2001 From: Jorge Gustavo Rocha Date: Sun, 6 Oct 2019 18:02:23 +0100 Subject: [PATCH] fill username from current_user on the server side for Postgresql --- src/providers/postgres/qgspostgresprovider.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/providers/postgres/qgspostgresprovider.cpp b/src/providers/postgres/qgspostgresprovider.cpp index 98665e0197a..e8c259ee9bc 100644 --- a/src/providers/postgres/qgspostgresprovider.cpp +++ b/src/providers/postgres/qgspostgresprovider.cpp @@ -4738,7 +4738,7 @@ bool QgsPostgresProviderMetadata::saveStyle( const QString &uri, const QString & ",styleSLD xml" ",useAsDefault boolean" ",description text" - ",owner varchar(63)" + ",owner varchar(63) DEFAULT CURRENT_USER" ",ui xml" ",update_time timestamp DEFAULT CURRENT_TIMESTAMP" ")" ) ); @@ -4769,9 +4769,9 @@ bool QgsPostgresProviderMetadata::saveStyle( const QString &uri, const QString & // two values are both replaced in the final .arg call of the string construction. QString sql = QString( "INSERT INTO layer_styles(" - "f_table_catalog,f_table_schema,f_table_name,f_geometry_column,styleName,styleQML,styleSLD,useAsDefault,description,owner%11" + "f_table_catalog,f_table_schema,f_table_name,f_geometry_column,styleName,styleQML,styleSLD,useAsDefault,description%11" ") VALUES (" - "%1,%2,%3,%4,%5,XMLPARSE(DOCUMENT %16),XMLPARSE(DOCUMENT %17),%8,%9,%10%12" + "%1,%2,%3,%4,%5,XMLPARSE(DOCUMENT %16),XMLPARSE(DOCUMENT %17),%8,%9%12" ")" ) .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) @@ -4780,7 +4780,6 @@ bool QgsPostgresProviderMetadata::saveStyle( const QString &uri, const QString & .arg( QgsPostgresConn::quotedValue( styleName.isEmpty() ? dsUri.table() : styleName ) ) .arg( useAsDefault ? "true" : "false" ) .arg( QgsPostgresConn::quotedValue( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.username() ) ) .arg( uiFileColumn ) .arg( uiFileValue ) // Must be the final .arg replacement - see above @@ -4818,7 +4817,6 @@ bool QgsPostgresProviderMetadata::saveStyle( const QString &uri, const QString & ",styleQML=XMLPARSE(DOCUMENT %12)" ",styleSLD=XMLPARSE(DOCUMENT %13)" ",description=%4" - ",owner=%5" " WHERE f_table_catalog=%6" " AND f_table_schema=%7" " AND f_table_name=%8" @@ -4826,7 +4824,6 @@ bool QgsPostgresProviderMetadata::saveStyle( const QString &uri, const QString & " AND styleName=%10" ) .arg( useAsDefault ? "true" : "false" ) .arg( QgsPostgresConn::quotedValue( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.username() ) ) .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) .arg( QgsPostgresConn::quotedValue( dsUri.table() ) )