I have a Profile field holding the gender of the user. It has Male or Female choises. The users who didn't choose have NULL valu in the datatable. But when I try to filter them through a view it only returns users who have empty string and not NULL, because the SQL query is something like this:

WHERE sex NOT IN('Male', 'Female')

How can I find the NULL values?

Comments

skein’s picture

Version: 5.x-1.6 » 6.x-2.9
dawehner’s picture

What is this kind of profile field?

It is not so hard to patch views to allow to select also is empty(NULL);

skein’s picture

It's a select Type

dawehner’s picture

StatusFileSize
new375 bytes

Here is a easy patch.

First it should be discussed what for profile fields should allow empty.

skein’s picture

Hello,

Sorry to bring this up again, but I tried your patch and it didn't work. Did i misunderstand something?

dawehner’s picture

Status: Active » Needs work

Mh so

Offlein’s picture

I think I see what the problem was. That patch is bad, as far as I can tell.
He wrote:

         'argument' => array(
           'handler' => 'views_handler_argument_string',
         ),
        'allow empty' => TRUE,
       );

When it should be:

         'argument' => array(
           'handler' => 'views_handler_argument_string',
           'accept_null' => TRUE,
         ),
       );

It is "accept_null" instead of "allow empty". Also, it has to go inside that array. This is roughly around Line 152 in views/modules/profile.views.inc. You will need to clear your caches.

michl6’s picture

subscribing

Offlein’s picture

Status: Needs work » Needs review

This should probably be "Needs review". I think that patch is fine with my change.

dawehner’s picture

Status: Needs review » Needs work

@offlein

See skeins comment.

Additional:

First it should be discussed what for profile fields should allow empty.

is still open.

esmerel’s picture

Status: Needs work » Closed (won't fix)

No work done on patch in more than 3 months.

Offlein’s picture

StatusFileSize
new377 bytes

Hi, sorry, I didn't come back to this.
@Dereine, Skein's comment is in reference to your patch not working. I wrote how to fix the patch, but did not reroll. I am including it here (your patch, edited, but not actually rerolled).

I am not really sure what "First it should be discussed what for profile fields should allow empty" means -- but at first blush it seems outside the scope of this issue?
I was using it to get Profile "selection" fields (I think) to operate when a value has not been selected?

iamjon’s picture

Status: Closed (won't fix) » Needs review

Can anyone update that this patch actually worked for them?

Marked #977060: Profile filter for EMPTY as a duplicate.

Offlein’s picture

@iamjon Sorry, I didn't reopen this I guess. Did the patch not work for you? What was the error? I believe it worked for me back when I rolled it in September. Or did it apply correctly, but did not do the expected functionality?

dawehner’s picture

Status: Needs review » Needs work

@offlein
iamjon is part of the views bug squad team, so he takes care about the patches.

      $this->accept_null = (bool) $this->definition['accept null'];

so your patch will not work. It needs a space instead of a "_"

gease’s picture

Seems you are talking about different things. accept null makes new choice appear, 'IS NULL' or 'IS NOT NULL', in the filter options. allow empty makes empty form field match not only an empty field value (''), but also NULL field value.
I think that the latter needs to be incorporated in Views (I'm using current version of 6.x-3)

mradcliffe’s picture

Version: 6.x-2.9 » 7.x-3.x-dev
Status: Needs work » Needs review
StatusFileSize
new1.36 KB

This one hasn't been worked on in a while. Updating to latest version and attached patch.

dawehner’s picture

Do we really care about profile module integration in d7?
In general this patch looks fine.

chris matthews’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs reroll

The 7 year old patch in #17 does not apply to the latest views 7.x-3.x-dev and if still applicable needs a reroll.

Checking patch modules/profile.views.inc...
error: while searching for:
        ),
        'filter' => array(
          'handler' => 'views_handler_filter_string',
        ),
      );

error: patch failed: modules/profile.views.inc:130
error: modules/profile.views.inc: patch does not apply
andrew answer’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new1.39 KB

Patch rerolled.

damienmckenna’s picture

Assigned: skein » Unassigned

FYI the "assigned" field is for indicating that you're actively working on an issue, if you're not actively working on an issue please leave it set to "unassigned". Thank you.