>
> 2. A query object represents a sql 'where' clause like, myquery = 
>>> (db.mytable.myfield != None) | (db.mytable.myfield > 'A')
>>>      Can't the same thing be done like, rows = 
>>> db((db.mytable.myfield!=None) | (db.mytable.myfield >'A')) 
>>>       what is the need of having a query object?
>>>
>>
>>  What is your proposed alternative?
>>
>> using, myset = db((db.mytable.myfield!None)|(db.mytable.myfield>'A')) and 
> then
>             rows = myset.select()
> will do the same thing, will it? so that we can skip two lines , one
> defining the myquery(db.mytable.myfield!None)|(db.mytable.myfield>'A'),
> then calling myset=db(myquery)
>

Oh, certainly, there's no need to define the query first and then pass it 
to db(). Your alternative is actually the more common usage. I thought you 
were suggesting there is no need for a separate query object at all. It can 
be useful in some cases, though. Consider a base query to which you might 
want to add various optional conditions:

base_query = (db.mytable.myfield != None)

You might want to add additional conditions to that query in different 
scenarios:

db(base_query & (db.mytable.myfield > 'A'))

You might also want to use the same query with different db objects.

Anthony
 

Reply via email to