Skip to content

Commit

Permalink
[offline editing] Fix broken attribute change handling with string va…
Browse files Browse the repository at this point in the history
…lues containing single quote
  • Loading branch information
nirvn committed Jun 10, 2021
1 parent 451cc66 commit 757c6f4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/qgsofflineediting.cpp
Expand Up @@ -1654,12 +1654,14 @@ void QgsOfflineEditing::committedAttributeValuesChanges( const QString &qgisLaye
QgsAttributeMap attrMap = cit.value();
for ( QgsAttributeMap::const_iterator it = attrMap.constBegin(); it != attrMap.constEnd(); ++it )
{
QString value = it.value().type() == QVariant::StringList || it.value().type() == QVariant::List ? QgsJsonUtils::encodeValue( it.value() ) : it.value().toString();
value.replace( QLatin1String( "'" ), QLatin1String( "''" ) ); // escape quote
QString sql = QStringLiteral( "INSERT INTO 'log_feature_updates' VALUES ( %1, %2, %3, %4, '%5' )" )
.arg( layerId )
.arg( commitNo )
.arg( fid )
.arg( it.key() ) // attr
.arg( it.value().type() == QVariant::StringList || it.value().type() == QVariant::List ? QgsJsonUtils::encodeValue( it.value() ) : it.value().toString() ); // value
.arg( it.key() ) // attribute
.arg( value );
sqlExec( database.get(), sql );
}
}
Expand Down

0 comments on commit 757c6f4

Please sign in to comment.