Skip to content
Permalink
Browse files

fix editing of NULL values (fixes 0 to NULL, and fixes setting of NUL…

…L values in postgres)
  • Loading branch information
3nids committed Jul 30, 2014
1 parent e642231 commit 54e3feacb11ba36463c7f97ecae114392a2d4479
Showing with 5 additions and 3 deletions.
  1. +4 −2 src/gui/qgsattributeform.cpp
  2. +1 −1 src/providers/postgres/qgspostgresprovider.cpp
@@ -154,7 +154,9 @@ bool QgsAttributeForm::save()
{
QVariant dstVar = dst[eww->fieldIdx()];
QVariant srcVar = eww->value();
if ( dstVar != srcVar && srcVar.isValid() )
// need to check dstVar.isNull() != srcVar.isNull()
// otherwise if dstVar=NULL and scrVar=0, then dstVar = srcVar
if ( ( dstVar != srcVar || dstVar.isNull() != srcVar.isNull() ) && srcVar.isValid() )
{
dst[eww->fieldIdx()] = srcVar;

@@ -192,7 +194,7 @@ bool QgsAttributeForm::save()
int n = 0;
for ( int i = 0; i < dst.count(); ++i )
{
if ( dst[i] == src[i] || !dst[i].isValid() )
if ( ( dst[i] == src[i] && dst[i].isNull() == src[i].isNull() ) || !dst[i].isValid() )
{
QgsDebugMsg( "equal or invalid destination" );
QgsDebugMsg( QString( "dst:'%1' (type:%2,isNull:%3,isValid:%4)" )
@@ -2024,7 +2024,7 @@ bool QgsPostgresProvider::changeAttributeValues( const QgsChangedAttributesMap &
}
else
{
sql += quotedValue( siter->toString() );
sql += quotedValue( *siter );
}
}
catch ( PGFieldNotFound )

0 comments on commit 54e3fea

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