Closed alfonsodg closed 10 years ago
From mulone.m...@gmail.com on September 10, 2010 11:31:11
From this thread: http://groups.google.com/group/web2py/t/db2e3e424d0557d0 I continue here because google groups don't like my reply :O
This is the result in gae, wrong because there are items with keywords with 'moon', 'planets' http://img837.imageshack.us/img837/3900/wronggae.png This is the result in sqlite, showing correct: http://img825.imageshack.us/img825/2457/goodsqlite.png Diferent results in Gae, than sqlite.
I think this is because in gae need a list to pass to " IN " (contains), not an str.
keys_planets = db(db.testing.keywords.contains('planets')).select() keys_moon = db(db.testing.keywords.contains('moon')).select()
or the problem is in insert...
Easy solution to the problem change in web2py/gluon/contrib/gql.py to change to this:
def contains(self, value): if self.type.startswith('list:'): if isinstance(value, (unicode, str) ): value = [value] return Query(self, 'IN', value) else: raise RuntimeError, "Not supported"
In gae doesn't show any record with keywords 'planet' and 'moon' You can verified here: http://web2pytesting.appspot.com/ultimatelist/ -------------
db.define_table('tags', Field('id', 'id'), Field('name'),format='%(name)s') db.define_table('testing', Field('id', 'id'), Field('keywords', 'list:string'), Field('numbers', 'list:integer'), Field('tags', 'list:reference tags'), migrate=True) testing = db(db.testing.id>0).select() if not testing: tag1 = db.tags.insert(name="TAG1") tag2 = db.tags.insert(name="TAG2") tag3 = db.tags.insert(name="TAG3") tag4 = db.tags.insert(name="TAG4") tag5 = db.tags.insert(name="TAG5") tag6 = db.tags.insert(name="TAG6") id1 = db.testing.insert(keywords=['planets', 'moon', 'space'],numbers=[1, 11, 111, 0],tags=[tag1, tag2, tag3]) id2 = db.testing.insert(keywords=['planets', 'mars', 'space'],numbers=[2, 22, 222, 0],tags=[tag1, tag4, tag5]) id2 = db.testing.insert(keywords=['planets', 'mercury',
def index(): keys_planets = db(db.testing.keywords.contains('planets')).select() keys_moon = db(db.testing.keywords.contains('moon')).select() number_0 = db(db.testing.numbers.contains('0')).select() number_1 = db(db.testing.numbers.contains('1')).select() return dict(keys_planets=keys_planets, keys_moon=keys_moon, number_0=number_0, number_1=number_1)
Attachment: web2py.app.ultimatelist.w2p
Original issue: http://code.google.com/p/web2py/issues/detail?id=108
From massimod...@gmail.com on September 10, 2010 09:54:31
Status: Fixed
From mulone.m...@gmail.com on September 10, 2010 11:31:11
From this thread: http://groups.google.com/group/web2py/t/db2e3e424d0557d0 I continue here because google groups don't like my reply :O
This is the result in gae, wrong because there are items with keywords with 'moon', 'planets' http://img837.imageshack.us/img837/3900/wronggae.png This is the result in sqlite, showing correct: http://img825.imageshack.us/img825/2457/goodsqlite.png Diferent results in Gae, than sqlite.
I think this is because in gae need a list to pass to " IN " (contains), not an str.
keys_planets = db(db.testing.keywords.contains('planets')).select() keys_moon = db(db.testing.keywords.contains('moon')).select()
or the problem is in insert...
Easy solution to the problem change in web2py/gluon/contrib/gql.py to change to this:
PROBLEM TEST:
In gae doesn't show any record with keywords 'planet' and 'moon' You can verified here: http://web2pytesting.appspot.com/ultimatelist/ -------------
in db.py
db.define_table('tags', Field('id', 'id'), Field('name'),format='%(name)s') db.define_table('testing', Field('id', 'id'), Field('keywords', 'list:string'), Field('numbers', 'list:integer'), Field('tags', 'list:reference tags'), migrate=True) testing = db(db.testing.id>0).select() if not testing: tag1 = db.tags.insert(name="TAG1") tag2 = db.tags.insert(name="TAG2") tag3 = db.tags.insert(name="TAG3") tag4 = db.tags.insert(name="TAG4") tag5 = db.tags.insert(name="TAG5") tag6 = db.tags.insert(name="TAG6") id1 = db.testing.insert(keywords=['planets', 'moon', 'space'],numbers=[1, 11, 111, 0],tags=[tag1, tag2, tag3]) id2 = db.testing.insert(keywords=['planets', 'mars', 'space'],numbers=[2, 22, 222, 0],tags=[tag1, tag4, tag5]) id2 = db.testing.insert(keywords=['planets', 'mercury',
'space'],numbers=[3, 33, 333, 0],tags=[tag1, tag2, tag6])
controller/default.py
def index(): keys_planets = db(db.testing.keywords.contains('planets')).select() keys_moon = db(db.testing.keywords.contains('moon')).select() number_0 = db(db.testing.numbers.contains('0')).select() number_1 = db(db.testing.numbers.contains('1')).select() return dict(keys_planets=keys_planets, keys_moon=keys_moon, number_0=number_0, number_1=number_1)
Attachment: web2py.app.ultimatelist.w2p
Original issue: http://code.google.com/p/web2py/issues/detail?id=108