[SQL-CVS] r3031 - in SQLObject/branches/0.9: docs sqlobject sqlobject/tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2007-10-09 15:55:07
|
Author: phd Date: 2007-10-09 09:55:04 -0600 (Tue, 09 Oct 2007) New Revision: 3031 Modified: SQLObject/branches/0.9/docs/News.txt SQLObject/branches/0.9/sqlobject/sqlbuilder.py SQLObject/branches/0.9/sqlobject/tests/test_unicode.py Log: Fixed startswith/endswith/contains for UnicodeCol. Modified: SQLObject/branches/0.9/docs/News.txt =================================================================== --- SQLObject/branches/0.9/docs/News.txt 2007-10-09 15:54:47 UTC (rev 3030) +++ SQLObject/branches/0.9/docs/News.txt 2007-10-09 15:55:04 UTC (rev 3031) @@ -278,6 +278,8 @@ * Fixed StringCol and UnicodeCol: use sqlType with MSSQL. +* Fixed startswith/endswith/contains for UnicodeCol. + Other Changes ------------- Modified: SQLObject/branches/0.9/sqlobject/sqlbuilder.py =================================================================== --- SQLObject/branches/0.9/sqlobject/sqlbuilder.py 2007-10-09 15:54:47 UTC (rev 3030) +++ SQLObject/branches/0.9/sqlobject/sqlbuilder.py 2007-10-09 15:55:04 UTC (rev 3031) @@ -343,7 +343,20 @@ if isinstance(other, unicode): other = other.encode(self.column.dbEncoding) return SQLOp('<>', self, other) + def startswith(self, s): + if isinstance(s, unicode): + s = s.encode(self.column.dbEncoding) + return STARTSWITH(self, s) + def endswith(self, s): + if isinstance(s, unicode): + s = s.encode(self.column.dbEncoding) + return ENDSWITH(self, s) + def contains(self, s): + if isinstance(s, unicode): + s = s.encode(self.column.dbEncoding) + return CONTAINSSTRING(self, s) + registerConverter(UnicodeField, SQLExprConverter) Modified: SQLObject/branches/0.9/sqlobject/tests/test_unicode.py =================================================================== --- SQLObject/branches/0.9/sqlobject/tests/test_unicode.py 2007-10-09 15:54:47 UTC (rev 3030) +++ SQLObject/branches/0.9/sqlobject/tests/test_unicode.py 2007-10-09 15:55:04 UTC (rev 3031) @@ -69,3 +69,17 @@ assert len(rows) == 2 rows = list(TestUnicode.selectBy(col1=u'\u00f0', col2=u'test')) assert len(rows) == 0 + + # starts/endswith/contains + rows = list(TestUnicode.select(TestUnicode.q.col1.startswith("test"))) + assert len(rows) == 1 + rows = list(TestUnicode.select(TestUnicode.q.col1.endswith("test"))) + assert len(rows) == 2 + rows = list(TestUnicode.select(TestUnicode.q.col1.contains("test"))) + assert len(rows) == 2 + rows = list(TestUnicode.select(TestUnicode.q.col1.startswith(u"\u00f0"))) + assert len(rows) == 1 + rows = list(TestUnicode.select(TestUnicode.q.col1.endswith(u"\u00f0"))) + assert len(rows) == 1 + rows = list(TestUnicode.select(TestUnicode.q.col1.contains(u"\u00f0"))) + assert len(rows) == 1 |