Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Bugfix][Server] WFS: Add primary keys to request to build Server Fea…
…ture Id
  • Loading branch information
rldhont committed Nov 8, 2019
1 parent 520fe74 commit 49c0524
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
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 49c0524

Please sign in to comment.