On Friday, March 23, 2012 10:09:07 PM UTC-4, Limedrop wrote:
>
> Thanks for the information.  Unfortunately, in my case I really do 
> need to store the raw query in the session...and then convert it back 
> to a Query so I can then add a few more filters before the final 
> select(). Has anyone managed to store a representation of a query in 
> the session? 
>

If you are using an SQL database, and the initial query is for a subset of 
records in a specific table, you might be able to use "belongs", which can 
accept a query string; so:

# compute complicated query; use _select instead of select
sqlquery = db(table)(...)(...)._select(table.id)

# store sqlquery in your string storage, etc; it is a string.
#  e.g. put it in your session (but under no circumstance in a form/request 
# variable or a cookie - that would make your app vulnerable to SQL 
injection)

# retrieve your sqlquery string from the secure storage

# add additional conditions
finalquery = db(table.id.belongs(sqlquery) & table.field1=='field1value')



Reply via email to