Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #32730 from rldhont/fix-server-wfs-add-primary-key…
…s-to-request-for-fid

[Bugfix][Server] WFS: Add primary keys to request to build Server Feature Id
  • Loading branch information
rldhont committed Nov 8, 2019
2 parents 9dbfb6a + 2a227fd commit ebd4bb7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/server/services/wfs/qgswfsgetfeature.cpp
Expand Up @@ -323,6 +323,7 @@ namespace QgsWfs
featureRequest.setFlags( featureRequest.flags() | QgsFeatureRequest::NoGeometry );
else
featureRequest.setFlags( featureRequest.flags() | ( withGeom ? QgsFeatureRequest::NoFlags : QgsFeatureRequest::NoGeometry ) );

// subset of attributes
featureRequest.setSubsetOfAttributes( attrIndexes );
#ifdef HAVE_SERVER_PYTHON_PLUGINS
Expand All @@ -338,8 +339,28 @@ namespace QgsWfs
featureRequest.setSubsetOfAttributes(
accessControl->layerAttributes( vlayer, attributes ),
vlayer->fields() );
attrIndexes = featureRequest.subsetOfAttributes();
}
#endif

// Force pkAttributes in subset of attributes for primary fid building
const QgsAttributeList pkAttributes = provider->pkAttributeIndexes();
if ( !pkAttributes.isEmpty() )
{
QgsAttributeList subsetOfAttrs = featureRequest.subsetOfAttributes();
for ( int idx : pkAttributes )
{
if ( !subsetOfAttrs.contains( idx ) )
{
subsetOfAttrs.prepend( idx );
}
}
if ( subsetOfAttrs.size() != featureRequest.subsetOfAttributes().size() )
{
featureRequest.setSubsetOfAttributes( subsetOfAttrs );
}
}

if ( onlyOneLayer )
{
requestPrecision = QgsServerProjectUtils::wfsLayerPrecision( *project, vlayer->id() );
Expand Down

0 comments on commit ebd4bb7

Please sign in to comment.