Skip to content
Permalink
Browse files

[wfs] fix turning attribute value to NULL

  • Loading branch information
3nids committed May 24, 2018
1 parent 5eddbb6 commit 12cb6fc6290b62b50eef8c5cea42d813f9e822ab
Showing with 19 additions and 6 deletions.
  1. +19 −6 src/providers/wfs/qgswfsprovider.cpp
@@ -1049,9 +1049,16 @@ QString QgsWFSProvider::convertToXML( const QVariant &value )
if ( value.type() == QVariant::DateTime )
{
QDateTime dt = value.toDateTime().toUTC();
valueStr.sprintf( "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ",
dt.date().year(), dt.date().month(), dt.date().day(),
dt.time().hour(), dt.time().minute(), dt.time().second(), dt.time().msec() );
if ( !dt.isNull() )
{
valueStr.sprintf( "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ",
dt.date().year(), dt.date().month(), dt.date().day(),
dt.time().hour(), dt.time().minute(), dt.time().second(), dt.time().msec() );
}
else
{
valueStr = QString();
}
}
return valueStr;
}
@@ -1095,9 +1102,15 @@ bool QgsWFSProvider::changeAttributeValues( const QgsChangedAttributesMap &attr_
propertyElem.appendChild( nameElem );

QDomElement valueElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, QStringLiteral( "Value" ) );
QDomText valueText = transactionDoc.createTextNode( convertToXML( attMapIt.value() ) );
valueElem.appendChild( valueText );
propertyElem.appendChild( valueElem );

if ( attMapIt.value().isValid() && !attMapIt.value().isNull() )
{
// WFS does not support :nil='true'
// if value is NULL, do not add value element
QDomText valueText = transactionDoc.createTextNode( convertToXML( attMapIt.value() ) );
valueElem.appendChild( valueText );
propertyElem.appendChild( valueElem );
}

updateElem.appendChild( propertyElem );
}

0 comments on commit 12cb6fc

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