when one of them not blank then another means:
blank value['min'] = -inf.
blank value['max'] = +inf.

file: views_handler_filter_numeric.inc
line: 220

function op_between($field) {
   if ($this->operator == 'between') {
     if ($this->value['min']!="") $this->query->add_where($this->options['group'], "$field >= %d", $this->value['min']);
     if ($this->value['max']!="") $this->query->add_where($this->options['group'], "$field <= %d", $this->value['max']);
   }
   else {
     $this->query->add_where($this->options['group'], "$field <= %d OR $field >= %d", $this->value['min'], $this->value['max']);
   }
}

Comments

deadman’s picture

+1 for this to be integrated

dawehner’s picture

Thats a good feature, but why not use the is greater or is smaller then, this would do the same.

edemus’s picture

It simplifies form. Lets say i want to have both 'between' 'greater/less than' and i dont want to expose operator. This is pretty handy

Im using this one for mine purpose:

function op_between($field) {
    if ($this->operator == 'between') {
			if($this->value['min']=='' AND $this->value['max']!=''){
			$this->query->add_where($this->options['group'], "$field <= %d", $this->value['max']);
			}
			elseif($this->value['min']!='' AND $this->value['max']==''){
			$this->query->add_where($this->options['group'], "$field >= %d", $this->value['min']);
			}
			else{
				$this->query->add_where($this->options['group'], "$field >= %d", $this->value['min']);
				$this->query->add_where($this->options['group'], "$field <= %d", $this->value['max']);
			}
    }
    else {
      $this->query->add_where($this->options['group'], "$field <= %d OR $field >= %d", $this->value['min'], $this->value['max']);
    }
  }

and for float type views_handler_filter_float.inc on line 10.

function op_between($field) {
    if ($this->operator == 'between') {
			if($this->value['min']=='' AND $this->value['max']!=''){
			$this->query->add_where($this->options['group'], "$field <= %f", $this->value['max']);
			}
			elseif($this->value['min']!='' AND $this->value['max']==''){
			$this->query->add_where($this->options['group'], "$field >= %f", $this->value['min']);
			}
			else{
				$this->query->add_where($this->options['group'], "$field >= %f", $this->value['min']);
				$this->query->add_where($this->options['group'], "$field <= %f", $this->value['max']);
			}
    }
    else {
      $this->query->add_where($this->options['group'], "$field <= %f OR $field >= %f", $this->value['min'], $this->value['max']);
    }
  }

Emil

esmerel’s picture

Status: Active » Postponed

This would be better served if it were a real patch :)

merlinofchaos’s picture

Category: feature » task
Status: Postponed » Active

This needs someone to work on it.

dawehner’s picture

I'm wondering whether it makes sense to call another op_simple here, if the cases mentioned above should be used.

merlinofchaos’s picture

You mean, if one or the other is empty, pass through to op_simple? I think the operator would have to be mangled for that to really work.

dawehner’s picture

You mean, if one or the other is empty, pass through to op_simple? 

Exactly.

Oh i see the problem. What about adding an optional value parameter to the op callbacks?

Wappie08’s picture

Title: make min and max blank values means inf. in operator 'between' » make min and max blank values means inf. in filter operator 'between'
Version: 6.x-2.x-dev » 7.x-3.x-dev

Hello, I also experience this in the 7.x version with (only) a "between" operator on a filter:

- when not entering a value all values are shown (right behavior)
- when only entering the max field the list is limited (right behavior)
- when only entering the min field no results are returned!

I'm filtering an integer field.


Greetings Wappie

Wappie08’s picture

This seems to be related to #856238: exposed filter of created date with "Is between" and optional returns empty results maybe. Feel free to put it 6.x again!

tamerzg’s picture

For D7 you can use change file: views_handler_filter_numeric.inc like this:

function op_between($field) {
    if ($this->operator == 'between') {
      if ($this->value['max'] == "") {
        $this->query->add_where($this->options['group'], $field, $this->value['min'], '>=');
      }
      else {
        $this->query->add_where($this->options['group'], $field, array($this->value['min'], $this->value['max']), 'BETWEEN');
      }
      
    }
    else {
      $this->query->add_where($this->options['group'], db_or()->condition($field, $this->value['min'], '<=')->condition($field, $this->value['max'], '>='));
    }
  }
onelittleant’s picture

+1

Ctrl-E’s picture

+1

Mr. Red’s picture

Priority: Normal » Major
Issue summary: View changes

When I use a filter with no maximum (['max']) value I don't see results in views. Is the problem still relevant?

MustangGB’s picture

Priority: Major » Normal
MustangGB’s picture

Category: Task » Feature request