> Thanks for this. I've been puzzling over it myself the last couple of > days. It'd be helpful if your explanation, or at least a summary of it, > appeared in The Book. > > Would .belongs() work as expected (over True/False/None)? >
Yep. Think to belongs() (that translates to an IN clause) as a handy decorator over OR-ifying your list of values .... the problem is that the "ORification" just does column = value OR column = othervalue OR .... Now, the real demistyfication gets to the bottom.....t-sql standards dictate that any comparison (=, <>, etc) against a NULL value evaluates to False (don't blame backends engineers: Codd invented the relational model, bottomline: Codd is a superhero). Although it doesn't raise an error, querying WHERE column = NULL doesn't return any result (unless you force a really-its-going-to-be-superdeprecated-dont-do-that-youre-going-to-hell mode in some backends) So, WHERE column IN (NULL, othervalue) doesn't return NULL columns either... Working as a DBA often side-by-side with coders, I often quote the following (don't really know who is the original author, multiple sources report it). It kinda represent at best the really different mindsets ^_^ Q(dba): what is NULL? A(coder): a NULL value A(dba): Nope, it isn't a value This is the reeeeally short story. The long one is basically on the lines of "its there since the beginning, lets don't get messy", but its explained really well in the wikipedia article https://en.wikipedia.org/wiki/Null_%28SQL%29 . If you reach the end alive, you may laugh once or twice in the process but hey, you're definitely not alone. -- --- 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.