Skip to main content
added 244 characters in body
Source Link
Letharion
  • 27.5k
  • 11
  • 83
  • 141

I have a Views filter handler, which does

$this->query->add_where(
  $this->options['group'],
  $this->real_field,
  vms_get_current_mlid(),
  $this->operator = ($this->operator == '=') ? 'IN' : 'NOT IN'
);

Which initially looks fine, but fails with "NOT IN", when the field value is NULL, as NOT IN (100) does not return TRUE for a NULL value, which is what I would like.

When the operator is 'NOT IN', I need to add a "OR IS NULL" operator as well, but still keep it within the same group.

If the filters are

Node is "page" AND NID_REFERENCE NOT IN (100, 101, 102)

I would like that to become

Node is "page" AND (NID_REFERENCE NOT IN (100, 101, 102) OR NID_REFERENCE IS NOT NULL)

How do I do that?

I have a Views filter handler, which does

$this->query->add_where(
  $this->options['group'],
  $this->real_field,
  vms_get_current_mlid(),
  $this->operator = ($this->operator == '=') ? 'IN' : 'NOT IN'
);

Which initially looks fine, but fails with "NOT IN", when the field value is NULL, as NOT IN (100) does not return TRUE for a NULL value, which is what I would like.

When the operator is 'NOT IN', I need to add a "OR IS NULL" operator as well.

How do I do that?

I have a Views filter handler, which does

$this->query->add_where(
  $this->options['group'],
  $this->real_field,
  vms_get_current_mlid(),
  $this->operator = ($this->operator == '=') ? 'IN' : 'NOT IN'
);

Which initially looks fine, but fails with "NOT IN", when the field value is NULL, as NOT IN (100) does not return TRUE for a NULL value, which is what I would like.

When the operator is 'NOT IN', I need to add a "OR IS NULL" operator as well, but still keep it within the same group.

If the filters are

Node is "page" AND NID_REFERENCE NOT IN (100, 101, 102)

I would like that to become

Node is "page" AND (NID_REFERENCE NOT IN (100, 101, 102) OR NID_REFERENCE IS NOT NULL)

How do I do that?

edited body
Source Link
Letharion
  • 27.5k
  • 11
  • 83
  • 141

I have a Views filter handler, which does

$this->query->add_where(
  $this->options['group'],
  $this->real_field,
  vms_get_current_mlid(),
  $this->operator = ($this->operator == '=') ? 'IN' : 'NOT IN'
);

Which initially looks fine, but fails with "NOT IN", when the field value is NULL, as "NOT IN (100)"NOT IN (100) does not return TRUE for a NULL value, which is what I would like.

When the operator is 'NOT IN', I need to add a "OR IS NULL" operator as well.

How do I do that?

I have a Views filter handler, which does

$this->query->add_where(
  $this->options['group'],
  $this->real_field,
  vms_get_current_mlid(),
  $this->operator = ($this->operator == '=') ? 'IN' : 'NOT IN'
);

Which initially looks fine, but fails with "NOT IN", when the field value is NULL, as "NOT IN (100)" does not return TRUE for a NULL value, which is what I would like.

When the operator is 'NOT IN', I need to add a "OR IS NULL" operator as well.

How do I do that?

I have a Views filter handler, which does

$this->query->add_where(
  $this->options['group'],
  $this->real_field,
  vms_get_current_mlid(),
  $this->operator = ($this->operator == '=') ? 'IN' : 'NOT IN'
);

Which initially looks fine, but fails with "NOT IN", when the field value is NULL, as NOT IN (100) does not return TRUE for a NULL value, which is what I would like.

When the operator is 'NOT IN', I need to add a "OR IS NULL" operator as well.

How do I do that?

Source Link
Letharion
  • 27.5k
  • 11
  • 83
  • 141

Add condition group in Views filter handler

I have a Views filter handler, which does

$this->query->add_where(
  $this->options['group'],
  $this->real_field,
  vms_get_current_mlid(),
  $this->operator = ($this->operator == '=') ? 'IN' : 'NOT IN'
);

Which initially looks fine, but fails with "NOT IN", when the field value is NULL, as "NOT IN (100)" does not return TRUE for a NULL value, which is what I would like.

When the operator is 'NOT IN', I need to add a "OR IS NULL" operator as well.

How do I do that?