CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Should the "is not null" filter match empty strings, or not?
Pages: [1]

Author Topic: Should the "is not null" filter match empty strings, or not?  (Read 1282 times)

TwoMice

  • I post frequently
  • ***
  • Posts: 214
  • Karma: 16
    • Emphanos
  • CiviCRM version: Always current stable version
  • CMS version: Drupal 7
Should the "is not null" filter match empty strings, or not?
August 22, 2011, 02:09:34 pm
Today I noticed that CiviReport's "Is Not Null" filter includes empty strings as not null.

I'm guessing that's because, well, empty strings are not null. Of course.

But now I'm looking for a way to filter for only records where a given field actually has a value, something like this: WHERE `my_field` is not null and `my_field` > ''

Is this currently possible?  Or, would it be worth trying to change the behavior of this filter? Any thoughts?

- Allen
Please consider contributing to help improve CiviCRM with the Make it Happen! initiative.

TwoMice

  • I post frequently
  • ***
  • Posts: 214
  • Karma: 16
    • Emphanos
  • CiviCRM version: Always current stable version
  • CMS version: Drupal 7
Re: Should the "is not null" filter match empty strings, or not?
August 22, 2011, 02:21:39 pm
Just to add a little background here:

We have a client who's created a custom field for participants called "Dietary Restrictions," and they're trying to get their report to show only participants who have a value in this field. "Not null" works fine for contacts who've never had a value in this field, but once they add a value, the field is never null again even after removing the value; so participants in that situation will show up on the report, even though the field is empty.

The client -- naturally, I think -- has a hard time understanding the difference, why the contact isn't in the list before adding the field value, but is in the list after the field value is cleared.

Thanks,
Allen
Please consider contributing to help improve CiviCRM with the Make it Happen! initiative.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Should the "is not null" filter match empty strings, or not?
August 23, 2011, 03:20:27 pm

should we rename IS NOT NULL to IS NOT EMPTY?

and then check that the string IS NOT NULL and length(string) > 0?

empty (or something other than NULL) seems a better word than null from a usability perspective. Also calling it something like empty makes it a bit more accurate for the techno-folks among us :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

TwoMice

  • I post frequently
  • ***
  • Posts: 214
  • Karma: 16
    • Emphanos
  • CiviCRM version: Always current stable version
  • CMS version: Drupal 7
Re: Should the "is not null" filter match empty strings, or not?
August 23, 2011, 03:41:00 pm
Yeah, I wouldn't expect most users to grok the concept of NULL, and certainly not to distinguish between NULL and empty().  For a user who can't distinguish between the two, the current label of "Is not empty (Null)" seems redundant, and on top of that produces an unexpected result.

So, yes, I'd say it should be relabeled and should be made to treat NULL and "" the same way.

I think one concern here may be that people have already built reports based on the current behavior. But if so, I'd like to hear how they're explaining that to their users.

- Allen
Please consider contributing to help improve CiviCRM with the Make it Happen! initiative.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Should the "is not null" filter match empty strings, or not?

This forum was archived on 2017-11-26.