Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[wfs] fix turning attribute value to NULL
  • Loading branch information
3nids committed May 24, 2018
1 parent 5eddbb6 commit 12cb6fc
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/providers/wfs/qgswfsprovider.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 );
}
Expand Down

0 comments on commit 12cb6fc

Please sign in to comment.