Provide a handler for IS NULL/IS NOT NULL

mfredrickson - May 9, 2007 - 03:35
Project:Views
Version:5.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Views provides a number of useful out of the box handlers (=/!=, LIKE, etc). I didn't see a IS NULL/IS NOT NULL handler.

The following patch provides a new function views_handler_filter_null that allows filters to limit on IS NULL/IS NOT NULL. The operator passed in must be 'IS' or 'IS NOT'.

This patch does not add a operator handler to provide the IS/IS NOT array. An example might look like:

<?php
array('IS NOT' => t('Does'), 'IS' => t('Does not'))
?>

This looks backwards, but it is correct as the completed phrases would be "Does" => IS NOT NULL and "Does not" => IS NULL.

If this patch is accepted, I promise to add a comment to the view developer handbook documenting it, such that it can be easily included in the main documentation.

The usecase for this functionality is the bio.module: filtering based on an author having crated a bio node or not.

AttachmentSize
views_20070508_is_null_handler.patch1000 bytes

#1

yched - May 9, 2007 - 12:15

mfredrickson : on a semi-related note, I'd be interestind in having your opinion on http://drupal.org/node/101050 :
'Empty / not empty' filter for CCK fields (or more ?) - relevant comments are #2-#3, #8-#9, #20)

I'm not trying to hijack this thread, though (even if I'm probably spamming it :-) ). +1 on the ready to use handler.

#2

mfredrickson - May 9, 2007 - 16:35

I think the link is topical. I commented in more detail over on that issue, but to paraphrase: this handler would be useful, if all CCK fields standardized on NULL as the empty indicator.

#3

merlinofchaos - July 14, 2007 - 18:54
Status:needs review» fixed

Committed to -dev.

#4

Anonymous - July 28, 2007 - 19:00
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.