Bug report #17122

regression: sql filtered spatialite layer (via OGR provider) break attribute / field values

Added by Mathieu Pellerin - nIRV almost 7 years ago. Updated almost 7 years ago.

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
  1. Open the attached test.qgs project
  2. 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)
  3. Close the attribute table
  4. Right click on the test layer, and select "filter..."
  5. Edit the filter string from "date" = '1971-01%' to "date" = '1971-02%'
  6. 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)

ogr_filter_regression.zip (424 KB) Mathieu Pellerin - nIRV, 2017-09-12 07:35 AM

Associated revisions

Revision 95cd8d74
Added by Sandro Mani almost 7 years ago

[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.

Revision 54653e4a
Added by Sandro Mani almost 7 years ago

[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 almost 7 years ago

  • Crashes QGIS or corrupts data changed from No to Yes
  • Priority changed from Normal to High

#2 Updated by Sandro Mani almost 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 almost 7 years ago

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

Also available in: Atom PDF