Hi,
need to set up a view with argument over a checkbox, so potential values are 0 and 1. 1 works without problems, 0 however is being translated into "IS NULL" in the SQL query, which isnt the same and results in an empty listing. Got the latest view 2.6. Tryied it with text and integer fields, both the same, works on nid's though, so must be a problem of CCK. Am I doing something wrong or is it a bug?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

electricmonk’s picture

Same behavior here - CCK Number field with 2 possible values - 0 or 1, adding an argument and it translates to IS NULL when the value is 0.

electricmonk’s picture

Project: Content Construction Kit (CCK) » Views (for Drupal 7)
Version: 6.x-2.4 » 6.x-2.6
Component: Views Integration » Code
Status: Active » Needs review
FileSize
635 bytes

OK, the problem is in Views, file views_handler_argument_many_to_one.inc. Moving this to Views and adding a patch which seems to work - please review and check that it didn't interfere with any expected behavior.

merlinofchaos’s picture

Status: Needs review » Needs work

I think this may break the 'Uncategorized' item for taxonomy. In order to be fixed properly, this probably needs a setting in the definition so that things like taxonomy can keep using 0 for uncategorized, and other systems can have a 0 as an actual value.

M_Z’s picture

Status: Needs review » Needs work

Maybe this issue is a duplicate of http://drupal.org/node/296732

But especially if this unwanted behaviour comes with a (numeric) checkbox field, then I found a workaround that I post here because this issue is dealing with checkboxes.

If your argument will run through basic validation (not validation option 'numeric') then a given argument string like '0' or any other string will result in the correct WHERE condition.
This is due to replacement of your given string to 0 when the replacement for %d placeholder in db_query() function is running.

sphopkins’s picture

M_Z’s picture

@shopkins (#5):
I am not sure if both issues are related: this issue is dealing with an argument handler, but #559102 is dealing with a field handler (and there is a new patch).

sphopkins’s picture

Yeah looking to test that patch http://drupal.org/node/559102#comment-2495742 today or tomorrow...

dawehner’s picture

Status: Needs work » Needs review
FileSize
1.25 KB

Here comes a patch. I did not tested the patch well.

merlinofchaos’s picture

Status: Needs review » Needs work

Oh man. Mixing spaces and _ in a definition term is going to confuse people.

Also as with a previous patch I marked 'needs work' the command needs to be documented in the doxygen at the top of the class.

Otherwise this looks very promising.

dawehner’s picture

Status: Needs work » Needs review
FileSize
1.63 KB

Yeah this was shit. Here is an update with class documentation

merlinofchaos’s picture

Status: Needs work » Fixed

Hooray to see this fixed! COmmitted to all branches.

jvandooren’s picture

Warning: this change is not yet included in the current 6.x-2.8 version (it is in the 6.x-2.x-dev).
If anyone wants to apply the patch mentioned in comment #10: there is a small bug in the patch.

Change

if (isset($this->argument)) {
   $empty = TRUE;
}

To

if (!isset($this->argument)) {
   $empty = TRUE;
}

Notice the exclamation mark... This is correct in 6.x-2.x-dev.

merlinofchaos’s picture

Releases are static; 2.8 won't be changed, so it won't ever be included in 2.8. It will be included in 2.9 when we roll another release.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.