summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES2
-rw-r--r--lib/sqlalchemy/sql.py4
-rw-r--r--test/sql/select.py9
3 files changed, 13 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index da87a0041..dbeffbe5d 100644
--- 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
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py
index 92b51dd25..5ceb9bdea 100644
--- a/lib/sqlalchemy/sql.py
+++ b/lib/sqlalchemy/sql.py
@@ -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)
diff --git a/test/sql/select.py b/test/sql/select.py
index d8b872098..37c597a8c 100644
--- a/test/sql/select.py
+++ b/test/sql/select.py
@@ -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")