View Single Post
Old 07-07-2013, 08:19 AM   #7
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,525
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by theducks View Post
and if you use a Tristate Yes/No/Blank, your logic thinking gets a twist


to find Blank or No: not #colkey:true
I think you mean not tristate. In Tristate (which most yes/no columns are), the above test will give you the same as #colkey:false, or just cells that are not set to anything. #colkey:true is true for both yes and no.

When not using tristate, the "unset" value is effectively forced to 'no' and the meaning of :true and :false change. The test #colkey:true matches only 'yes' and #colkey:false matches everything else.

For those of you who can read code, the exact tests are:
Code:
if not bools_are_tristate:
    if val is None or not val:  # item is None or set to false
        if query in (self.local_no, self.local_unchecked, '_no', 'false'):
            matches.add(item[0])
    else:  # item is explicitly set to true
        if query in (self.local_yes, self.local_checked, '_yes', 'true'):
            matches.add(item[0])
else:
    if val is None:
        if query in (self.local_empty, self.local_blank, '_empty', 'false'):
            matches.add(item[0])
    elif not val:  # is not None and false
        if query in (self.local_no, self.local_unchecked, '_no', 'true'):
            matches.add(item[0])
    else:  # item is not None and true
        if query in (self.local_yes, self.local_checked, '_yes', 'true'):
            matches.add(item[0])
chaley is offline   Reply With Quote