Skip to content

Commit 71e0116

Browse files
committedJan 23, 2019
Server WFS NULL values support
- expose nillable in describefeaturetype - serve xsi:nil="true" in getfeature - check for NULL in transactions and report an error Fixes #20961 - plus some other unreported
1 parent 847e7ef commit 71e0116

File tree

41 files changed

+322
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+322
-272
lines changed
 

‎src/server/services/wfs/qgswfsdescribefeaturetype.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ namespace QgsWfs
7979
// test oFormat
8080
if ( oFormat == QgsWfsParameters::Format::NONE )
8181
throw QgsBadRequestException( QStringLiteral( "Invalid WFS Parameter" ),
82-
"OUTPUTFORMAT " + wfsParameters.outputFormatAsString() + "is not supported" );
82+
QStringLiteral( "OUTPUTFORMAT %1 is not supported" ).arg( wfsParameters.outputFormatAsString() ) );
8383

8484
QgsAccessControl *accessControl = serverIface->accessControls();
8585

@@ -346,6 +346,11 @@ namespace QgsWfs
346346
}
347347
}
348348

349+
if ( !( field.constraints().constraints() & QgsFieldConstraints::Constraint::ConstraintNotNull ) )
350+
{
351+
attElem.setAttribute( QStringLiteral( "nillable" ), QStringLiteral( "true" ) );
352+
}
353+
349354
sequenceElem.appendChild( attElem );
350355

351356
QString alias = field.alias();

‎src/server/services/wfs/qgswfsgetfeature.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,16 +1334,16 @@ namespace QgsWfs
13341334
{
13351335
continue;
13361336
}
1337-
if ( featureAttributes[idx].isNull() )
1338-
{
1339-
continue;
1340-
}
13411337
const QgsField field = fields.at( idx );
13421338
const QgsEditorWidgetSetup setup = field.editorWidgetSetup();
13431339
QString attributeName = field.name();
13441340

13451341
QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( ' ', '_' ).replace( cleanTagNameRegExp, QString() ) );
13461342
QDomText fieldText = doc.createTextNode( encodeValueToText( featureAttributes[idx], setup ) );
1343+
if ( featureAttributes[idx].isNull() )
1344+
{
1345+
fieldElem.setAttribute( QStringLiteral( "xsi:nil" ), QStringLiteral( "true" ) );
1346+
}
13471347
fieldElem.appendChild( fieldText );
13481348
typeNameElement.appendChild( fieldElem );
13491349
}
@@ -1435,16 +1435,18 @@ namespace QgsWfs
14351435
{
14361436
continue;
14371437
}
1438-
if ( featureAttributes[idx].isNull() )
1439-
{
1440-
continue;
1441-
}
1438+
14421439
const QgsField field = fields.at( idx );
14431440
const QgsEditorWidgetSetup setup = field.editorWidgetSetup();
1441+
14441442
QString attributeName = field.name();
14451443

14461444
QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( ' ', '_' ).replace( cleanTagNameRegExp, QString() ) );
14471445
QDomText fieldText = doc.createTextNode( encodeValueToText( featureAttributes[idx], setup ) );
1446+
if ( featureAttributes[idx].isNull() )
1447+
{
1448+
fieldElem.setAttribute( QStringLiteral( "xsi:nil" ), QStringLiteral( "true" ) );
1449+
}
14481450
fieldElem.appendChild( fieldText );
14491451
typeNameElement.appendChild( fieldElem );
14501452
}

0 commit comments

Comments
 (0)
Please sign in to comment.