]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- fixed "where"/"from" criterion of select() to accept a unicode string
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 23 Jun 2007 18:47:28 +0000 (18:47 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 23 Jun 2007 18:47:28 +0000 (18:47 +0000)
in addition to regular string - both convert to text()

CHANGES
lib/sqlalchemy/sql.py
test/sql/select.py

diff --git a/CHANGES b/CHANGES
index da87a0041cc6fada32aeb314293517fc511f27e5..dbeffbe5dae7a8e7276e2278c58d1631558132db 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -25,6 +25,8 @@
       to polymorphic mappers that are using a straight "outerjoin"
       clause
 - sql
+    - fixed "where"/"from" criterion of select() to accept a unicode string
+      in addition to regular string - both convert to text()
     - added standalone distinct() function in addition to column.distinct()
       [ticket:558]
     - result.last_inserted_ids() should return a list that is identically
index 92b51dd2589b156464cf31a16c5affc7d5054553..5ceb9bdea3beaa0fdae8e403aac699107cc7a383 100644 (file)
@@ -2938,7 +2938,7 @@ class Select(_SelectBaseMixin, FromClause):
         self._append_condition('having', having)
 
     def _append_condition(self, attribute, condition):
-        if type(condition) == str:
+        if isinstance(condition, basestring):
             condition = _TextClause(condition)
         self.__wherecorrelator.traverse(condition)
         self._process_froms(condition, False)
@@ -2957,7 +2957,7 @@ class Select(_SelectBaseMixin, FromClause):
         self.__correlated[from_obj] = from_obj
 
     def append_from(self, fromclause):
-        if type(fromclause) == str:
+        if isinstance(fromclause, basestring):
             fromclause = FromClause(fromclause)
         self.__correlator.traverse(fromclause)
         self._process_froms(fromclause, True)
index d8b872098a20fa7e8438bd0affff14aa4053c75e..37c597a8c8a889942cb7a1f28c5d1dccf4495641 100644 (file)
@@ -400,6 +400,7 @@ WHERE mytable.myid = myothertable.otherid) AS t2view WHERE t2view.mytable_myid =
             "select * from foo where lala = bar"
         )
 
+        # test bytestring
         self.runtest(select(
             ["foobar(a)", "pk_foo_bar(syslaal)"],
             "a = 12",
@@ -407,6 +408,14 @@ WHERE mytable.myid = myothertable.otherid) AS t2view WHERE t2view.mytable_myid =
         ), 
         "SELECT foobar(a), pk_foo_bar(syslaal) FROM foobar left outer join lala on foobar.foo = lala.foo WHERE a = 12")
 
+        # test unicode
+        self.runtest(select(
+            [u"foobar(a)", u"pk_foo_bar(syslaal)"],
+            u"a = 12",
+            from_obj = [u"foobar left outer join lala on foobar.foo = lala.foo"]
+        ), 
+        u"SELECT foobar(a), pk_foo_bar(syslaal) FROM foobar left outer join lala on foobar.foo = lala.foo WHERE a = 12")
+
         # test building a select query programmatically with text
         s = select()
         s.append_column("column1")