queries=[]
if arg1 == "xyz": queries.append(db.abc.id > 0)
if arg2 == "xyz": queries.append(db.def.id > 0)
query = reduce(lambda a,b:(a&b),queries)

On Dec 30, 12:20 pm, vvk <varunk.ap...@gmail.com> wrote:
> How to initialize a NULL query
>
> My query should be ANDed with various tables depending on arguments I
> receive.
>
> Like:
>     if arg1 == "xyz":
>          query = (db.abc.id > 0)
>     if arg2 == "xyz":
>          query = (db.def.id > 0) & query
>
> In my "second if" condition, if "first if" condition is not executed,
> error occurs that query is not initialised. How to tackle this ?
>
> On Dec 30, 10:51 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > This:
>
> > query = (-1)
>
> > is not a valid query. The fact it works with sqlite is a miracle.
>
> > On Dec 30, 11:43 am, vvk <varunk.ap...@gmail.com> wrote:
>
> > > query = (-1)
> > > query = (db.somedb.id > 0) & query
>
> > > This querying worked with SQLITE. But it's giving following error with
> > > postgres:
>
> > > ProgrammingError: argument of AND must be type boolean, not type
> > > integer
> > > LINE 1: ...rchase WHERE (purchase.timeofpurchase<='2009-12-29' AND
> > > -1);
>
> > > i) I think there is problem with type conversions, is there a way
> > > out ?
>
> > > ii) Is there a way to initialize a NULL query (like query = (-1) I did
> > > earlier ?)
>
>

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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