attached is a patch for gql.py. Please review and Massimo, if people
like this, can we add it to trunk?
what does it do? it allows you to do key queries on Google App Engine.
this means that you can now perform all ID queries on tables in google
app engine. for example:
belongs = db(db.test_tbl.id.belongs([69126,69127])).select()
eq = db(db.test_tbl.id==69126).select()
neq = db(db.test_tbl.id!=69126).select()
lt = db(db.test_tbl.id<69126).select()
gt = db(db.test_tbl.id>69126).select()
lte = db(db.test_tbl.id<=69126).select()
gte = db(db.test_tbl.id>=69126).select()
all = db(db.test_tbl.id>0).select()
it also adds "__key__" to _extra on each row in the result...just in
case you really wanted to see that google key.
if i missed some test cases please let me know and i'll verify them as well.
thanks!
Christian
- no more __key__ in _extra (and in understand why it breaks backward
compatibility now....just needed to think about it)
- since it is illegal in web2py to have "_" start a field name,
"__key__" can never be a field name and never queried on. so removed
the support that i had tried to add in my previous version of the patch
- since previously web2py required that id on GAE be a long, i
continued that theme, which simplifies the code. basically the id>0 and
id==x case were already special cases in the code, if you use any other
operators on ID this version of the code detects field.type=='id' and
will use "__key__" in the query (regardless of the name you have
assigned your key, and with out my changing the name hack)
hopefully you agree that this is better, and thanks for your patience
and code review! let me know if there are any other changes that i
should make.
christian
i don't think there are any other clauses that you can put ID in, is
that correct?
also, if anyone is using GAE development server with sqlite, key queries
don't work properly there (spent 4 hours trying to figure out what i
messed up to find out that others reported it as a bug to google).
christian
On 06/09/2010 08:54 PM, Christian Foster Howes wrote: