Bug report #17122
regression: sql filtered spatialite layer (via OGR provider) break attribute / field values
Status: | Closed | ||
---|---|---|---|
Priority: | High | ||
Assignee: | Sandro Mani | ||
Category: | Vectors | ||
Affected QGIS version: | master | Regression?: | Yes |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | Yes | Resolution: | |
Crashes QGIS or corrupts data: | Yes | Copied to github as #: | 25021 |
Description
The following commit, https://github.com/nirvn/QGIS/commit/217e70067f6b2c1d9be506e01e5f458277b4bf62, created a regression whereas a spatialite layer (loaded via the OGR provider) has its attributes / fields messed up when a SQL filter is added / edited.
Steps to reproduce- Open the attached test.qgs project
- Open the test layer's attribute table, and look at the values for the AIRCRAFT values (F4, F100, etc.) as well as the presence (why?) of orig_ogc_fid (effectively replacing ogc_fid)
- Close the attribute table
- Right click on the test layer, and select "filter..."
- Edit the filter string from "date" = '1971-01%' to "date" = '1971-02%'
- Open the test layer's attribute table, and note a/ the presence of ogc_fid as the first field, and b/ the brokeness of values for subsequent fields (for e.g. AIRCRAFT now shows 2 instead of aircraft names)
Associated revisions
[OGR] Ensure subset string is set when reopening dataset
QgsOgrProvider::reloadData calls close() and open(), which in turn called setSubsetString with mSubsetString.
Since setSubsetString does nothing if the passed sql string is equal to mSubsetString, this resulted in the
substring not being set on re-open. This commit clears mSubsetString before calling setSubsetString, and
blocks signals when calling setSubsetString to avoid an endless recursion of emit dataChanged -> reload.
Fixes #17122.
[OGR] Ensure subset string is set when reopening dataset
QgsOgrProvider::reloadData calls close() and open(), which in turn called setSubsetString with mSubsetString.
Since setSubsetString does nothing if the passed sql string is equal to mSubsetString, this resulted in the
substring not being set on re-open. This commit clears mSubsetString before calling setSubsetString, and
blocks signals when calling setSubsetString to avoid an endless recursion of emit dataChanged -> reload.
Fixes #17122.
History
#1 Updated by Giovanni Manghi about 7 years ago
- Crashes QGIS or corrupts data changed from No to Yes
- Priority changed from Normal to High
#2 Updated by Sandro Mani about 7 years ago
- Pull Request or Patch supplied changed from No to Yes
- Assignee set to Sandro Mani
Actually this is an issue which was already present previously but was exposed more visibly by 217e70067f6b2c1d9be506e01e5f458277b4bf62.
Proposed fix:
https://github.com/qgis/QGIS/pull/5181
#3 Updated by Sandro Mani about 7 years ago
- % Done changed from 0 to 100
- Status changed from Open to Closed
Applied in changeset qgis|95cd8d744d9fc06c673c758668775f4177c0777d.