Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetFID incorrect after sorting layer #5967

Closed
jontwo opened this issue Jun 22, 2022 · 0 comments
Closed

GetFID incorrect after sorting layer #5967

jontwo opened this issue Jun 22, 2022 · 0 comments
Assignees

Comments

@jontwo
Copy link

jontwo commented Jun 22, 2022

Expected behavior and actual behavior.

When a layer is sorted using ExecuteSQL with ORDER BY, the FIDs in the layer are changed such GetFeature returns the wrong feature when using an fid obtained from GetFID.

Steps to reproduce the problem.

See this gist.

In a nutshell:

  • add some differently sized features to a layer
  • sorted_lyr = ds.ExecuteSQL(f"SELECT * FROM lname ORDER BY OGR_GEOM_AREA ASC")
  • make a list of FIDs by iterating the layer and calling GetFID
  • for each fid in the list, call GetFeature and check the fid (and area) of the returned feature

Operating system

Rocky Linux release 8.6 (Green Obsidian)

GDAL version and provenance

GDAL 3.4.1 on Python 3.8.12

@rouault rouault self-assigned this Jun 23, 2022
rouault added a commit that referenced this issue Jun 23, 2022
OGRSQL: fix GetFeature() to return a feature such that GetFeature(fid).GetFID() == fid (fixes #5967)
rouault added a commit that referenced this issue Jun 24, 2022
rouault added a commit that referenced this issue Jun 24, 2022
[Backport release/3.5] OGRSQL: fix GetFeature() to return a feature such that GetFeature(fid).GetFID() == fid (fixes #5967)
g8sqh pushed a commit to g8sqh/gdal that referenced this issue Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants