Skip to content
Permalink
Browse files

Code review && QgsLogger::warning if user tries to insert/change gene…

…rated field.
  • Loading branch information
espinafre authored and nyalldawson committed Jun 2, 2020
1 parent 72d0150 commit 04b5f79fa7b13989169265b4c8aee55e1cdc8812
Showing with 5 additions and 5 deletions.
  1. +5 −5 src/providers/postgres/qgspostgresprovider.cpp
@@ -889,9 +889,9 @@ bool QgsPostgresProvider::loadFields()
" LEFT OUTER JOIN ( SELECT DISTINCT indrelid, indkey, indisunique FROM pg_index WHERE indisunique ) uniq ON attrelid=indrelid AND attnum::text=indkey::text "

" WHERE attrelid IN %3"
).arg( connectionRO()->pgVersion() >= 100000 ? QStringLiteral( ", attidentity" ) : QString() )
.arg( connectionRO()->pgVersion() >= 120000 ? QStringLiteral( ", attgenerated" ) : QString() )
.arg( tableoidsFilter );
).arg( connectionRO()->pgVersion() >= 100000 ? QStringLiteral( ", attidentity" ) : QString(),
connectionRO()->pgVersion() >= 120000 ? QStringLiteral( ", attgenerated" ) : QString(),
tableoidsFilter );

QgsPostgresResult fmtFieldTypeResult( connectionRO()->PQexec( sql ) );
for ( int i = 0; i < fmtFieldTypeResult.PQntuples(); ++i )
@@ -2345,7 +2345,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist, Flags flags )

if ( !mGeneratedValues.value( idx, QString() ).isEmpty() )
{
QgsDebugMsg( QStringLiteral( "Skipping field %1 (idx %2) which is GENERATED." ).arg( fieldname, idx ) );
QgsLogger::warning( tr( "Skipping field %1 which is GENERATED." ).arg( fieldname ) );
continue;
}

@@ -2958,7 +2958,7 @@ bool QgsPostgresProvider::changeAttributeValues( const QgsChangedAttributesMap &

if ( mGeneratedValues.contains( siter.key() ) && !mGeneratedValues.value( siter.key(), QString() ).isEmpty() )
{
pushError( tr( "Changing the value of GENERATED field %1 is not allowed." ).arg( fld.name() ) );
QgsLogger::warning( tr( "Changing the value of GENERATED field %1 is not allowed." ).arg( fld.name() ) );
continue;
}

0 comments on commit 04b5f79

Please sign in to comment.
You can’t perform that action at this time.