Hi,
I know the documentation explains that you cannot do 'complex' datetime
queries in web2py with GAE, however I am hoping that this does not qualify
as 'complex'.
I am trying to use the smartquery (experimental) functionality that it
works really well in the SQLlite db.
Unfortunately, the same call fails in GAE.
I am using Version 1.99.7, and the latest GAE.
To reproduce the problem, I have a table with a datetime field:
db.define_table('call',
Field('start', 'datetime'),
Field('end', 'datetime'),
Field('created_on','datetime',default=request.now,
label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
label=T('Modified On'),writable=False,readable=False,
update=request.now))
I have created an REST interface using the smartquery functionality, that
works well on SQL lite:
@request.restful()
#@auth.requires_login()
def calldatasmart():
response.view = 'generic.'+request.extension
def GET(search):
try:
rows = db.smart_query([db.call],search).select()
return dict(result=rows)
except RuntimeError:
raise HTTP(400,"Invalid search string")
return locals()
Now if I do the following I get the correct response from SQLLite and an
error from GAE. (Note: I created the data using the default=request.now
function, so it should be a datetime in the datastore.
http://localhost:8080/api/calldatasmart.json?search=call.created_on is
greater than "2012-03-20"
Error in GAE:
File "/........./gluon/dal.py", line 3396, in represent
time_items = map(int,str(obj)[11:].strip().split(':')[:3])
ValueError: invalid literal for int() with base 10: ''
Question:
1. Is this a bug in the experimental smartquery functionality?
2. Does all datetime comparisons not work with GAE?
3. Can I use a GQL call to do it, or is there a way in Web2py to do it
nicely?
BTW: I have not coded as much as this for 15 years, and I have not had so
much fun in getting back into it. So thankyou all for the work you have
done to create web2py...
Doug