mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
fix editing of NULL values (fixes 0 to NULL, and fixes setting of NULL values in postgres)
This commit is contained in:
parent
4995305adc
commit
aa40d61a8c
@ -161,7 +161,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;
|
||||
|
||||
@ -199,7 +201,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 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user