]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- unicode fix for startswith()/endswith() [ticket:296]
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 5 Sep 2006 15:39:59 +0000 (15:39 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 5 Sep 2006 15:39:59 +0000 (15:39 +0000)
CHANGES
lib/sqlalchemy/sql.py
test/sql/select.py

diff --git a/CHANGES b/CHANGES
index c011c6285b29f9d78a25f1daa62aa96ae0d053d9..8ec7f60e9f17e7c14d7d70a98773e5751bb918d9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -67,6 +67,7 @@ against datetimes that dont).
 count() [ticket:287]
 - deregister Table from MetaData when autoload fails; [ticket:289]
 - import of py2.5s sqlite3 [ticket:293]
+- unicode fix for startswith()/endswith() [ticket:296]
 
 0.2.7
 - quoting facilities set up so that database-specific quoting can be
index d2e270c32cfb2af7df53dcfd7ea8cfa771c629cc..ab371dcb915ecb7971cf9f78a8b5fd2e4a6af883 100644 (file)
@@ -554,9 +554,9 @@ class CompareMixin(object):
             # statement out of it.
             return self._compare('IN', union(parens=True, *other))
     def startswith(self, other):
-        return self._compare('LIKE', str(other) + "%")
+        return self._compare('LIKE', other + "%")
     def endswith(self, other):
-        return self._compare('LIKE', "%" + str(other))
+        return self._compare('LIKE', "%" + other)
     def label(self, name):
         return Label(name, self, self.type)
     def distinct(self):
index 7711e2908b22199b139bdffef23342be3036c3f7..6eeef270407d78d8fb2be8e221ab50ff661f01bb 100644 (file)
@@ -212,6 +212,14 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A
             literal("a") + literal("b") * literal("c"), ":literal + (:liter_1 * :liter_2)"
         )
 
+    def testunicodestartswith(self):
+       string = u"hi \xf6 \xf5"
+       self.runtest(
+               table1.select(table1.c.name.startswith(string)),
+               "SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE mytable.name LIKE :mytable_name",
+               checkparams = {'mytable_name': u'hi \xf6 \xf5%'},
+       )
+
     def testmultiparam(self):
         self.runtest(
             select(["*"], or_(table1.c.myid == 12, table1.c.myid=='asdf', table1.c.myid == 'foo')),