Bug report #16798

Virtual layers don't work correctly with FilterFid feature requests

Added by Nyall Dawson almost 7 years ago. Updated over 6 years ago.

Status:Closed
Priority:Normal
Assignee:Hugo Mercier
Category:Virtual Layers
Affected QGIS version:2.18.10 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:24697

Description

Not sure if this is a regression or something which was never supported, but virtual layers always return the same feature when attempting to fetch a particular feature with a filterfid request.

Steps to reproduce:

1. load two layers
2. create a virtual layer using a cross join type "select * from layerA, layerB"
3. Try fetching features using a non restricted request, eg:

ids = [f.id() for f in layer.getFeatures()]

this works OK
4. Try fetching a specific feature:

f.getFeatures(QgsFeatureRequest.setFilterFid(ids[4])).next()

Regardless of the feature id requested, only the first feature in the table is returned.

This may be due to the query not having a unique key field - but if that's the case it becomes impossible to create cross join type virtual layers (since sqllite doesn't have a row_number() type function which could be used to create fake unique ids in the query).

This breaks various QGIS functionality with the resultant layer - e.g. it can't be used with atlas. Possibly #15709 is related too.

Associated revisions

Revision d0d88e44
Added by Paul Blottiere over 6 years ago

Fixes #16798 FilterFid feature requests with virtual layers

Revision 9f0985ff
Added by Paul Blottiere over 6 years ago

Merge pull request #5554 from pblottiere/bugfix_virtuallayer

[bugfix] Fixes #16798 FilterFid feature requests with virtual layers

Revision 577c1f2e
Added by Paul Blottiere over 6 years ago

Fixes #16798 FilterFid feature requests with virtual layers

Revision 485cd80a
Added by Paul Blottiere over 6 years ago

Merge pull request #5695 from pblottiere/bugfix_virtuallayer_218

[backport][bugfix] Fixes #16798 FilterFid feature requests with virtual layers

History

#1 Updated by Nyall Dawson over 6 years ago

This also affects copying from virtual layers

#2 Updated by Jürgen Fischer over 6 years ago

  • Category set to Unknown

#3 Updated by Jürgen Fischer over 6 years ago

  • Category changed from Unknown to Virtual Layers

#4 Updated by Paul Blottiere over 6 years ago

  • % Done changed from 0 to 100
  • Status changed from Open to Closed

Also available in: Atom PDF