Until now I assumed the problem of @Richard is that if a row has column == 
None, if he queries the table with column != True he expected the NULL row 
to show (because in python None is different from True).

~db.table.column=False will result in a WHERE NOT column = 'F'. You don't 
get any row holding column == None with that query.

What you said in your post

That would be false for False and true for True and None (NULL)
>

is what happens in python but not in any db backend, reason why it may seem 
cumbersome to users accustomed to "compare" in python vs in databases.

Little recap for everybody looking at this later....
db.define_table('thenulltest', Field('thenullablefield', 'boolean'))
<Table thenulltest (id,thenullablefield)>
>>> db.commit()
>>> db.thenulltest.insert()
1L
>>> db.thenulltest.insert(thenullablefield=True)
2L
>>> db.thenulltest.insert(thenullablefield=False)
3L
>>> for row in db(db.thenulltest).select():
...     print row
... 
<Row {'thenullablefield': None, 'id': 1L}>
<Row {'thenullablefield': True, 'id': 2L}>
<Row {'thenullablefield': False, 'id': 3L}>
>>> for row in db(db.thenulltest.thenullablefield==True).select(): print row
... 
<Row {'thenullablefield': True, 'id': 2L}>
>>> for row in db(db.thenulltest.thenullablefield!=True).select(): print row
... 
<Row {'thenullablefield': False, 'id': 3L}>
##only False is extracted, None is skipped
>>> for row in db(~(db.thenulltest.thenullablefield!=True)).select(): printrow
... 
<Row {'thenullablefield': True, 'id': 2L}>
##only True is extracted, None is skipped
>>> for row in db(~(db.thenulltest.thenullablefield==True)).select(): printrow
... 
<Row {'thenullablefield': False, 'id': 3L}>
##only False is extracted, None is skipped
>>> for row in db(~(db.thenulltest.thenullablefield==None)).select(): printrow
... 
<Row {'thenullablefield': True, 'id': 2L}>
<Row {'thenullablefield': False, 'id': 3L}>
##not None means both True OR False
>>> for row in db(db.thenulltest.thenullablefield==None).select(): print row
... 
<Row {'thenullablefield': None, 'id': 1L}>
##finally, the only query that returns the "None" Field






-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to