Bug report #16798
Virtual layers don't work correctly with FilterFid feature requests
|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|
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:
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.
Merge pull request #5554 from pblottiere/bugfix_virtuallayer
[bugfix] Fixes #16798 FilterFid feature requests with virtual layers