Achipa, thanks for your valuable words and I appreciate that. I'll
take your advice.

By the way, according to my test,
  db( ~ (db.Orders.special==True))
equals to:
  db(db.Orders.special != True)
and still equals to:
  db(db.Orders.special==False)

So you really have to do this to capture both:
  db((db.Orders.special==False)|(db.Orders.special==None))

Well, even above are not considered as a bug, I suggest at least these
example shall show up in web2py 's document of DAL, to remind people.
Do you think so, Massimo (if you are reading this)?


On Dec 12, 8:34 pm, achipa <attila.cs...@gmail.com> wrote:
> I might be very wrong on this, but it's actually correct that way.
> None is NOT a value (it is a const identifier) and hence you cannot/
> should not compare it by value or use logic operators on it. The same
> goes for databases' NULL. Take a look for example at mysql, when you
> do 'WHERE id = NULL' there, it will also hurt you - you should do 'id
> IS NULL' just as 'id is None' in Python. None evaluates to false under
> certain conditions so it might work depending on the expression but
> you'll do yourself a favor if you do not rely on this if it is part of
> a logical expression.
>
> For your specific example that would mean something along the lines of
> db.( ~ (db.Orders.special==True))
>
> If I'm cardinally wrong, please correct me.
>
> On Dec 12, 12:59 pm, Iceberg <iceb...@21cn.com> wrote:
>
> > Hi there,
>
> > I encounter a not-so-intuitive behavior when search in boolean field,
> > named
>
> > Giving the definition:
> >   SQLField('special', 'boolean', default=False)
> > And bear in mind that there are THREE kinds of value in this field:
> > True, False, and ""(None)!
>
> > When I search:
> >   db(db.Orders.special==True).select()
> > it works like a charm.
>
> > When I search:
> >   db(db.Orders.special!=True).select()
> > it equals to:
> >   db(db.Orders.special==False).select()
> > but not equals to:
> >   db((db.Orders.special==False)|(db.Orders.special==None)).select()
>
> > Do I have to use the last form to select all non-True records? Is this
> > an intended design, or a unexpected flaw?
>
> > Thanks in advance.
> > Iceberg
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to