On database level, NULL can be anything. DBMS defines it as an unknown
value. If you query non-True records, you'll be given only those
records that have defined not-True value (since it's boolean it has to
be False). NULL means "I'm not sure if this is True or False, value is
missing".
If you want NULL values, you always have to explicitly ask for them.

Since web2py DAL is translated into SQL, it's SQL semantics, not pythonic.

Marin

2011/7/28 Kenneth Lundström <kenneth.t.lundst...@gmail.com>:
> Default value could be a good solution, but I don't understand how I have
> never before run into this. Can't remember how many times I have used !=True
> to find all none True records. I have chosen not to use ==False as I know
> that default value is None for boolean. But I guess not so often has I
> havn't had problems with before.
>
> I understand that None is a little bit odd value for a record, but I don't
> understand why !=True is not working as None definitly is not True and we
> are looking for anything but True.
>
>
> Kenneth
>
>> Set the default value for your boolean column.  That way you won't
>> have any NULL values in there and you can select on True or False.
>>
>> If you don't like that solution, try (db.mytable.boolean==None) |
>> (db.mytable.boolean==False) in your where clause.
>>
>> If this conditions is ANDed with other conditions, be sure to enclose
>> it in parends to avoid order of evaluation problems.
>>
>> On Jul 28, 2:17 am, Kenneth Lundström<kenneth.t.lundst...@gmail.com>
>> wrote:
>>>
>>> Hello,
>>>
>>> is it so that if I query a table and ask to get all rows where a fields
>>> value is != True then all "None" rows are also exluded, only "False"
>>> rows are included?
>>>
>>> Kenneth
>
>

Reply via email to