Feature request #3337

Query Builder's data sampler doesn't use original dataset

Added by Aren Cambre almost 9 years ago. Updated about 7 years ago.

Status:Closed
Priority:Low
Assignee:Jürgen Fischer
Category:Vectors
Pull Request or Patch supplied:No Resolution:fixed
Easy fix?:No Copied to github as #:13397

Description

Suppose you use the Query Builder to filter data on a layer. Now suppose you want to later refine the query, perhaps by adding back some data you previously filtered our.

If I click on a field on the left side and then hit Sample or All under Values, the values are only returned from the filtered dataset, not from the original dataset.

Here's where it's a problem: I have a vector layer with field rte_class with values County Roads, FC Streets, On System Highways, and Toll Roads. I previously filtered the dataset so the SQL where clause says "rte_class" = 'On System Highways'. But I wanted to go back and add another value, but I don't remember what it is. I clicked on rte_class under Fields and hit All under Values, and the only value presented is On System Highways. The only way I got the other three fields back is to clear the filter and start over.

I think that sampled data should come from the original dataset, not the filtered version of the data. I've been debating bug vs. enhancement for this, but I think it's a bug because it precludes using the Query Builder to relax a filter unless I clear the filter totally.

Only after clearing the filter was I able to produce the desired where clause: "rte_class" = 'On System Highways' OR "rte_class" = 'Toll Roads'.

querybuilder.diff Magnifier (1.99 KB) Leyan Ouyang, 2012-06-29 07:20 PM


Related issues

Duplicated by QGIS Application - Bug report #5114: Query builder "sample" and "All" buttons stop to work if ... Closed 2012-02-29
Duplicated by QGIS Application - Bug report #7687: Query Builder Sample Restricted on Layer With Existing Query Closed 2013-04-23
Duplicated by QGIS Application - Bug report #7989: QGIS Nightly (June 2-3) Filter Vector, sql query Closed 2013-06-03

History

#1 Updated by Giovanni Manghi almost 8 years ago

  • Target version changed from Version 1.7.0 to Version 1.7.4

#2 Updated by Paolo Cavallini over 7 years ago

  • Target version changed from Version 1.7.4 to Version 1.8.0
  • Affected QGIS version set to master
  • Crashes QGIS or corrupts data set to No

#3 Updated by Leyan Ouyang about 7 years ago

I was also bitten by this bug. This is quite easy to fix if we just temporarily clear the query when getting the values to use the full dataset. There is of course a performance impact, but I think it is better than returning truncated results. Is there a more clever way to do this?

Patch attached.

#4 Updated by Jürgen Fischer about 7 years ago

  • Start date set to 2012-06-30
  • Pull Request or Patch supplied set to No
  • OS version deleted (7 x86)
  • Operating System deleted (Windows)
  • Tracker changed from Bug report to Feature request

I still don't see this a bug. It's just one way it can work. If you want to add filtered out data back, you need to clear the query first (maybe copying before and pasting it back afterwards). But if you want to filter out more, it's useful that you only need to consider values that are left in the filtered dataset. I consider that a feature, that we would loose if the behaviour was changed. But there might be a checkbox that lets the user decide, which approach to use.

#5 Updated by Jürgen Fischer about 7 years ago

  • Status changed from Open to Closed
  • Resolution set to fixed

implemented in d79c2963

#6 Updated by Aren Cambre about 7 years ago

The main problem is in relaxing a filter. As it is now, you can't relax it unless you clear the filter entirely and rebuild it.

#7 Updated by Jürgen Fischer about 7 years ago

Aren Cambre wrote:

The main problem is in relaxing a filter. As it is now, you can't relax it unless you clear the filter entirely and rebuild it.

Not sure what you mean. As it is now, checking the box, resets the filter before retrieving the samples.

Also available in: Atom PDF