On Thu, Mar 11, 2010 at 5:34 PM, Greg Milby <[email protected]> wrote:
> re: automatically escape % characters in the db query
> is this for a specific application, or everything (asking/wasn't specified)

I'm not sure what you mean by specific to an application.

In web.py 0.33, the following query would fail.

>>> db.query("SELECT * FROM thing WHERE key LIKE 'foo%'")
ERR: SELECT * FROM thing WHERE key LIKE 'foo%'
Traceback (most recent call last):
    ...
IndexError: list index out of range

The work around was to escape % with %%.

>>> db.query("SELECT * FROM thing WHERE key LIKE 'foo%%'")
0.22 (1): SELECT * FROM thing WHERE key LIKE 'foo%'
<web.utils.IterBetter instance at 0x16676e8>

In 0.34 this has been fixed.

>>> db.query("SELECT * FROM thing WHERE key LIKE 'foo%'")
0.0 (1): SELECT * FROM thing WHERE key LIKE 'foo%'
<web.utils.IterBetter instance at 0x1667580>

%% works still to provide backward-compatibility.

>>> db.query("SELECT * FROM thing WHERE key LIKE 'foo%%'")
0.0 (1): SELECT * FROM thing WHERE key LIKE 'foo%'
<web.utils.IterBetter instance at 0x16676e8>

Does this answer your question?

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to