Navigation Menu

Skip to content

Commit

Permalink
Code review && QgsLogger::warning if user tries to insert/change gene…
Browse files Browse the repository at this point in the history
…rated field.
  • Loading branch information
espinafre authored and nyalldawson committed Jun 2, 2020
1 parent 72d0150 commit 04b5f79
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 04b5f79

Please sign in to comment.