From: Mike Bayer Date: Sat, 23 Jun 2007 18:47:28 +0000 (+0000) Subject: - fixed "where"/"from" criterion of select() to accept a unicode string X-Git-Tag: rel_0_3_9~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7cfd3973ce7596091ec8abd1b314811716c8e93d;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - fixed "where"/"from" criterion of select() to accept a unicode string in addition to regular string - both convert to text() --- diff --git a/CHANGES b/CHANGES index da87a0041c..dbeffbe5da 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 92b51dd258..5ceb9bdea3 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 d8b872098a..37c597a8c8 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")