[SQL-CVS] r2913 - in SQLObject/trunk/sqlobject: . tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2007-09-14 14:36:44
|
Author: phd
Date: 2007-09-14 08:36:40 -0600 (Fri, 14 Sep 2007)
New Revision: 2913
Modified:
SQLObject/trunk/sqlobject/sqlbuilder.py
SQLObject/trunk/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/trunk/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/trunk/sqlobject/sqlbuilder.py 2007-09-14 14:36:28 UTC (rev 2912)
+++ SQLObject/trunk/sqlobject/sqlbuilder.py 2007-09-14 14:36:40 UTC (rev 2913)
@@ -888,9 +888,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/trunk/sqlobject/tests/test_select.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_select.py 2007-09-14 14:36:28 UTC (rev 2912)
+++ SQLObject/trunk/sqlobject/tests/test_select.py 2007-09-14 14:36:40 UTC (rev 2913)
@@ -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)
|