db.mytable.myfield.contains() gives an error Query Not Supported: parser stack overflow

57 views
Skip to first unread message

dave

unread,
Aug 17, 2013, 10:26:03 PM8/17/13
to
.
.
.
x
= ['a', 'b', 'c', ...]
queries
.append(db.mytable.myfield.contains(x))
query
= reduce(lambda a,b:(a&b),queries)
grid
= SQLFORM.grid(query, ...)

return (grid=grid)

gives an error of "Query Not Supported: parser stack overflow", if the list x has too many values, like around 100 or a 1000, I suspect its an sqlite limitation? can anyone suggest another succinct way of passing a list to a contain like operator or method. 

dave

unread,
Aug 17, 2013, 10:11:52 PM8/17/13
to web...@googlegroups.com
I guess nobody encountered this issue before?

Massimo Di Pierro

unread,
Aug 18, 2013, 4:06:39 AM8/18/13
to web...@googlegroups.com
I think by this:

= ['a', 'b', 'c', ...]
queries
.append(db.mytable.myfield.contains(x))

you mean:

= ['a', 'b', 'c', ...]

queries
.append(db.mytable.myfield.belongs(x))

You cannot pass a list to contains. That may part of the problem.
there may be other problems. Can you show more code or explain what the query is supposed to do?

Massimo

dave

unread,
Aug 18, 2013, 1:32:36 PM8/18/13
to
you can pass a list, http://www.web2py.com/book/default/chapter/06#like,-regexp,-startswith,-contains,-upper,-lower
It works fine for a small list, but when you get past a certain number maybe a 100 or a 1000, it gives an error, same thing with belongs. I think the nesting with the parenthesis becomes very high, and the stack overflows, I suspect it is an sqlite problem?
To explain what it does, the query is part of a larger dynamic query,

x = something
y
= something
z
= something
queries
=[] # an empty query to build a list upon
 
queries
.append(db.mytable.myfield_1.contains(x))
queries
.append(db.mytable.myfield_2.contains(y))
queries
.append(db.mytable.myfield_3.contains(z))
.
.
queries
.append(db.mytable.myfield_10.contains(a))

query
= reduce(lambda a,b:(a&b),queries)
grid
= SQLFORM.grid(query, ...)
return (grid=grid)
Reply all
Reply to author
Forward
0 new messages