I went through the code and was planning on proposing a recommendation - I can create the patch for the code if you think it's worthwhile. The behavior I would expect is that if None is provided in the contains() statement, it would just return no results (because GAE won't allow None in lists). I could modify the code in the gluon DAL if this would be acceptable.
On Nov 11, 12:07 pm, Massimo Di Pierro <massimo.dipie...@gmail.com> wrote: > session.company_id is None in your case and None cannot be contained > in a list of strings. > It has to fail in some place. We could catch the error somewhere else > and have a more meaningful error but you really want something like: > > if session.company_id: > rows = > db(db.Site_Main.companyID.contains(session.company_id)).select(db.Site_Main > .id) > else: > rows = [] > > On Nov 11, 10:20 am, pallav <pallav.n...@gmail.com> wrote: > > > > > > > > > Hi, > > > I am using version 1.99.2 of web2py and am getting an error when > > trying to run a query with "contains()" in Google App Engine. > > > The Model: > > ======== > > > db.define_table('Site_Main', > > Field('site', 'string', length=13), > > Field('companyID', 'list:integer'), > > Field('active', 'integer'), > > Field('syncToPalm', 'integer'), > > migrate=settings.migrate) > > > The Query: > > ======== > > > rows = > > db(db.Site_Main.companyID.contains(session.company_id)).select(db.Site_Main > > .id) > > > The Error: > > ======= > > Traceback (most recent call last): > > File "/home/pallav/Desktop/google_appengine/web2py/gluon/ > > restricted.py", line 194, in restricted > > exec ccode in environment > > File "/home/pallav/Desktop/google_appengine/web2py/applications/ > > samapp/controllers/datasync.py:sites", line 119, in <module> > > File "/home/pallav/Desktop/google_appengine/web2py/gluon/ > > globals.py", line 149, in <lambda> > > self._caller = lambda f: f() > > File "/home/pallav/Desktop/google_appengine/web2py/applications/ > > samapp/controllers/datasync.py:sites", line 42, in sites > > File "/home/pallav/Desktop/google_appengine/web2py/applications/ > > samapp/models/datasync/site_data.py", line 67, in read > > rows = > > db(db.Site_Main.companyID.contains(session.company_id)).select(db.Site_Main > > .id) > > File "/home/pallav/Desktop/google_appengine/web2py/gluon/dal.py", > > line 5697, in select > > return self.db._adapter.select(self.query,fields,attributes) > > File "/home/pallav/Desktop/google_appengine/web2py/gluon/dal.py", > > line 3351, in select > > (items, tablename, fields) = > > self.select_raw(query,fields,attributes) > > File "/home/pallav/Desktop/google_appengine/web2py/gluon/dal.py", > > line 3308, in select_raw > > filters = self.expand(query) > > File "/home/pallav/Desktop/google_appengine/web2py/gluon/dal.py", > > line 3192, in expand > > return expression.op(expression.first) > > TypeError: CONTAINS() takes exactly 3 arguments (2 given) > > > I have tried looking through the book, and the forums, and searched on > > Google but found no references to this specific error. Is something > > broken in the DAL related to GAE in the latest web2py? I am > > downloading Eclipse to see if I can just debug the DAL myself but any > > help is appreciated. > > > Thanks > > Pallav