Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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?
Comment | File | Size | Author |
---|---|---|---|
#10 | 496634-views-argument_is_null.patch | 1.63 KB | dawehner |
#8 | 496634-views-argument_is_null.patch | 1.25 KB | dawehner |
#2 | views_handler_argument_many_to_one.inc_.patch | 635 bytes | electricmonk |
Comments
Comment #1
electricmonk CreditAttribution: electricmonk commentedSame 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.
Comment #2
electricmonk CreditAttribution: electricmonk commentedOK, 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.
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedI 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.
Comment #4
M_Z CreditAttribution: M_Z commentedMaybe 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.
Comment #5
sphopkins CreditAttribution: sphopkins commentedIs this issue related to #559102: Views thinks that a 0 value is empty even when the box 'Count the number 0 as empty' is unchecked... ?
Still struggling with that one.
Comment #6
M_Z CreditAttribution: M_Z commented@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).
Comment #7
sphopkins CreditAttribution: sphopkins commentedYeah looking to test that patch http://drupal.org/node/559102#comment-2495742 today or tomorrow...
Comment #8
dawehnerHere comes a patch. I did not tested the patch well.
Comment #9
merlinofchaos CreditAttribution: merlinofchaos commentedOh 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.
Comment #10
dawehnerYeah this was shit. Here is an update with class documentation
Comment #11
merlinofchaos CreditAttribution: merlinofchaos commentedHooray to see this fixed! COmmitted to all branches.
Comment #12
jvandooren CreditAttribution: jvandooren commentedWarning: 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
To
Notice the exclamation mark... This is correct in 6.x-2.x-dev.
Comment #13
merlinofchaos CreditAttribution: merlinofchaos commentedReleases 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.