As it stands, views will not allow you to select "is null" or "is not null" in a numeric filter unless you have added entity references. Because of the critical difference between 0 and null in numeric data the use of the "is null" test is much more critical than it is for text type fields.

The patch here adds this capability by default. I set priority as "Normal" because there was no Priority = "This is really, really, really important if you want to handle large numerical datasets in Drupal".

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

robertwb’s picture

robertwb’s picture

Status: Active » Needs review

Queueing test bot

Status: Needs review » Needs work

The last submitted patch, 1: drupal-2438213-01.patch, failed testing.

robertwb’s picture

Status: Needs work » Needs review
FileSize
1.4 KB

Last patch failed because there was a test of the numeric filter "testAllowEmpty()" that specifically required that "allow empty" be false for ID types, and thus the test failed. I am not sure that I really understand the intent of a test to see if setting defaults have not changed, especially with something like this taht should be up to the user to decide if they want to use a given filter or not. In effect, this test seems to just be testing if the config options have changed or are auto-guessed properly? But anyhow, I updated the test coverage to be in line with the modified default setting.

 public function testAllowEmpty() {
    $view = $this->getBasicView();

    $view->display['default']->handler->override_option('filters', array(
      'id' => array(
        'id' => 'id',
        'table' => 'views_test',
        'field' => 'id',
        'relationship' => 'none',
      ),
     ),
      'age' => array(
        'id' => 'age',
        'table' => 'views_test',
        'field' => 'age',
        'relationship' => 'none',
      ),
    ));

    $view->set_display('default');
    $view->init_handlers();
    $id_operators = $view->filter['id']->operators();
    $age_operators = $view->filter['age']->operators();

    $this->assertTrue(isset($id_operators['empty']));
    $this->assertTrue(isset($id_operators['not empty']));
    $this->assertTrue(isset($age_operators['empty']));
    $this->assertTrue(isset($age_operators['not empty']));
  }



Chris Matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The 2 year old patch in #4 to views_handler_filter_numeric.inc does not apply to the latest views 7.x-3.x-dev and if still relevant needs to be rerolled.

Checking patch handlers/views_handler_filter_numeric.inc...
error: while searching for:
    return $options;
  }

  function operators() {
    $operators = array(
      '<' => array(

error: patch failed: handlers/views_handler_filter_numeric.inc:26
error: handlers/views_handler_filter_numeric.inc: patch does not apply

Checking patch tests/handlers/views_handler_filter_numeric.test...
Hunk #1 succeeded at 339 (offset -6 lines).
MustangGB’s picture

This looks great, very useful, thanks!

Andrew Answer’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
1.41 KB

Patch rerolled.

DamienMcKenna’s picture

Issue tags: +Needs change record

I think this deserves a change record, might someone be able to put together a draft for that? Thank you.

Also, has anyone compared how D9/10 handle this?