Navigation Menu

Skip to content

Commit

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

[Backport release-3_4][Bugfix][Server] WFS: Add primary keys to request to build Server Feature Id
  • Loading branch information
rldhont committed Nov 14, 2019
2 parents 766149b + 7d97ebe commit d350f44
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/server/services/wfs/qgswfsgetfeature.cpp
Expand Up @@ -330,6 +330,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 );

Expand All @@ -346,9 +347,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 d350f44

Please sign in to comment.