Author: phd
Date: 2007-09-14 08:36:16 -0600 (Fri, 14 Sep 2007)
New Revision: 2911
Modified:
SQLObject/branches/0.8/docs/News.txt
SQLObject/branches/0.8/sqlobject/sqlbuilder.py
SQLObject/branches/0.8/sqlobject/tests/test_select.py
Log:
Fixed a bug in sqlbuilder._LikeQuoted() - call sqlrepr() on the
expression to escape single quotes if the expression is a string.
Modified: SQLObject/branches/0.8/docs/News.txt
===================================================================
--- SQLObject/branches/0.8/docs/News.txt 2007-09-14 14:36:00 UTC (rev 2910)
+++ SQLObject/branches/0.8/docs/News.txt 2007-09-14 14:36:16 UTC (rev 2911)
@@ -192,6 +192,9 @@
* Remove 'limit' from SelectResults after setting start/end so .clone()
never see limit again.
+* Fixed a bug in sqlbuilder._LikeQuoted() - call sqlrepr() on the
+ expression to escape single quotes if the expression is a string.
+
Other Changes
-------------
Modified: SQLObject/branches/0.8/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/0.8/sqlobject/sqlbuilder.py 2007-09-14 14:36:00 UTC (rev 2910)
+++ SQLObject/branches/0.8/sqlobject/sqlbuilder.py 2007-09-14 14:36:16 UTC (rev 2911)
@@ -721,9 +721,11 @@
return "CONCAT(%s)" % ", ".join(values)
else:
return " || ".join(values)
- else: # assuming s is a string
- s = _quote_percent(s, db)
+ elif isinstance(s, (str, unicode)):
+ s = _quote_percent(sqlrepr(s, db)[1:-1], db)
return "'%s%s%s'" % (self.prefix, s, self.postfix)
+ else:
+ raise TypeError, "expected str, unicode or SQLExpression, got %s" % type(s)
def _quote_percent(s, db):
if db in ('postgres', 'mysql'):
Modified: SQLObject/branches/0.8/sqlobject/tests/test_select.py
===================================================================
--- SQLObject/branches/0.8/sqlobject/tests/test_select.py 2007-09-14 14:36:00 UTC (rev 2910)
+++ SQLObject/branches/0.8/sqlobject/tests/test_select.py 2007-09-14 14:36:16 UTC (rev 2911)
@@ -85,6 +85,7 @@
assert len(list(IterTest.select(IterTest.q.name.endswith('a')))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains('a')))) == 1
assert len(list(IterTest.select(IterTest.q.name.contains(func.lower('A'))))) == 1
+ assert len(list(IterTest.select(IterTest.q.name.contains("a'b")))) == 0
def test_select_getOne():
setupClass(IterTest)
|