I just spent some time trying to figure out how to execute the
equivalent of a "where col like '%text%'" query using SQLObject. I'm now
using the following:
results = Story.select(CONTAINSSTRING(Story.q.body, query))
This is a bit of an eye-sore, especially compared to the neat
Story.q.body.startswith('blah') and Story.q.body.endswith('blah') shortcuts.
Ideally I'd like to be able to perform this type of query using Python's
"in" operator. From reading through SQLBuilder.py this seems to be
already overloaded to support SQL "something IN ('blah1', 'blah2')"
operations. Is there any way this could be inteligently overloaded to
perform like %% queries on strings and IN queries on tuples?
Alternatively, a contains() method similar to startswith() and
endswith() would be useful.
Cheers,
Simon
|