Re: [web2py] bizzard issue with postgres web2py select IMPORTANT

2013-08-08 Thread Jonathan Lundell
On 8 Aug 2013, at 1:47 PM, Niphlod wrote: > 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) OK, that was confusing me, until I re

Re: [web2py] bizzard issue with postgres web2py select IMPORTANT

2013-08-08 Thread Niphlod
> 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) a

Re: [web2py] bizzard issue with postgres web2py select IMPORTANT

2013-08-08 Thread Niphlod
another piece of examples >>> for row in db(db.thenulltest.thenullablefield.belongs([True])).select(): print row ... >>> for row in db(db.thenulltest.thenullablefield.belongs([True,False])). select(): print row ... >>> for row in db(db.thenulltest.thenullablefield.belongs([True,False,None ]

Re: [web2py] bizzard issue with postgres web2py select IMPORTANT

2013-08-08 Thread Richard Vézina
Here : https://groups.google.com/d/msg/web2py/hQGyg6fL1Ls/zhxcWg7BsjYJ Was a type issue... Richard On Thu, Aug 8, 2013 at 3:47 PM, Richard Vézina wrote: > I have been quite puzzled with .belongs() in the pass... I don't remember > exactly was the cause of my problem at that time, I think it w

Re: [web2py] bizzard issue with postgres web2py select IMPORTANT

2013-08-08 Thread Richard Vézina
I have been quite puzzled with .belongs() in the pass... I don't remember exactly was the cause of my problem at that time, I think it was if I was passing a list to .belongs() and it was empty. I think I had asking about that and get a answer from Niphold to... Let me searche that... Richard On

Re: [web2py] bizzard issue with postgres web2py select IMPORTANT

2013-08-08 Thread Jonathan Lundell
On 8 Aug 2013, at 12:12 PM, Niphlod wrote: > 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

Re: [web2py] bizzard issue with postgres web2py select IMPORTANT

2013-08-08 Thread Niphlod
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 ho

Re: [web2py] bizzard issue with postgres web2py select IMPORTANT

2013-08-08 Thread Joe Barnhart
Hmmm... That's not quite what I suggested. I suggested WHERE NOT COLUMN = 'F' which I think would result in the OP wants, True and NULL would be grouped together and False would be separate. Or are you saying that web2py db adapters will take the construction ~db.table.column=False and turn

Re: [web2py] bizzard issue with postgres web2py select IMPORTANT

2013-08-08 Thread Richard Vézina
Thanks Niphold. I am aware of that, but forget about it sometimes :( I need bool to be NULL as I have more room for system evolution... Some bool field I set them to not null but some I keep them nullable that can bring me more insight on what going on with the record... Anyway thanks again... I

Re: [web2py] bizzard issue with postgres web2py select IMPORTANT

2013-08-08 Thread Niphlod
it would give the same result, its the exact same "mental-mistake" if you negate the filter you get exactly what you would get negating the operator i.e. WHERE NOT column = 'T' matches exactly WHERE COLUMN <> 'T' a column holding a NULL value is "non-existant" for any (and I mean, really a

Re: [web2py] bizzard issue with postgres web2py select IMPORTANT

2013-08-07 Thread Joe Barnhart
Not to be flip, but couldn't you just reverse the test and use ~(mytable.mybool==False)? That would be false for False and true for True and None (NULL) But I agree it is an interesting find, and I will watch out for this in my own code. Thanks for posting! -- Joe On Wednesday, August 7, 20

Re: [web2py] bizzard issue with postgres web2py select IMPORTANT

2013-08-07 Thread Niphlod
If you never used a db backend dealing with NULL values is a little bit different than dealing with None in python. While it's true that in python False != None and True != None, it's not the same in SQL. As much as the db engine knows, a column with a NULL value has no data to compare with, so

Re: [web2py] bizzard issue with postgres web2py select IMPORTANT

2013-08-07 Thread Richard Vézina
I expect it will include the NULL... I said different then TRUE I want the rest... I didn't know I had to take care of this... So I have to write this like that db((db.mytable.id == 1) & (db.mytable.mybool != True) & (db.mytable.mybool == None)).select() Thanks Richard On Wed, Aug 7, 2013 at

Re: [web2py] bizzard issue with postgres web2py select IMPORTANT

2013-08-07 Thread Niphlod
what did you expect ? Any query with a filter (unless IS NOT NULL) doesn't take into account the NULL value. It's a pretty standard behaviour in any SQL backend. If you need to get all rows with both False AND None values, you should do db((db.mytable.id == 1) & ((db.mytable.mybool != True) | (

Re: [web2py] bizzard issue with postgres web2py select IMPORTANT

2013-08-07 Thread Richard Vézina
Forgot to mention : web2py 2.4.7 postgres 9.1 under ubuntu 12.04 server 64 bit... Richard On Wed, Aug 7, 2013 at 5:00 PM, Richard wrote: > Hello, > > Found this not working : > > db((db.mytable.id == 1) & (db.mytable.mybool != True).select() > > That translate as : > SELECT * FROM mytable WHER

[web2py] bizzard issue with postgres web2py select IMPORTANT

2013-08-07 Thread Richard
Hello, Found this not working : db((db.mytable.id == 1) & (db.mytable.mybool != True).select() That translate as : SELECT * FROM mytable WHERE mytable.id = 1 AND mytable.mybool <> 'T' NO RECORD, BUT THERE IS A RECORD If i change the select like this : SELECT * FROM mytable WHERE mytable.id =