From: Mike Bayer Date: Sun, 4 Dec 2011 01:09:27 +0000 (-0500) Subject: - [bug] Fixed the error formatting raised when X-Git-Tag: rel_0_7_4~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c993de6cee97dc8c2c9ac0a988e410ccd7fa97c;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - [bug] Fixed the error formatting raised when a tuple is inadvertently passed to session.query() [ticket:2297]. --- diff --git a/CHANGES b/CHANGES index 89b07c4453..87036000a7 100644 --- a/CHANGES +++ b/CHANGES @@ -80,6 +80,10 @@ CHANGES a distinct entity when producing certain kinds of joined-inh joins. [ticket:2316] + - [bug] Fixed the error formatting raised when + a tuple is inadvertently passed to session.query() + [ticket:2297]. Also in 0.6.9. + - sql - [bug] related to [ticket:2316], made some adjustments to the change from [ticket:2261] diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index a875ad46d0..9c7ef7b8eb 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -3052,7 +3052,7 @@ class _ColumnEntity(_QueryEntity): if not isinstance(column, sql.ColumnElement): raise sa_exc.InvalidRequestError( "SQL expression, column, or mapped entity " - "expected - got '%r'" % column + "expected - got '%r'" % (column, ) ) # If the Column is unnamed, give it a diff --git a/test/orm/test_query.py b/test/orm/test_query.py index 25ab1a29d6..9ada53bfcd 100644 --- a/test/orm/test_query.py +++ b/test/orm/test_query.py @@ -432,6 +432,13 @@ class InvalidGenerationsTest(QueryTest, AssertsCompiledSQL): q = s.query(User) assert_raises(sa_exc.InvalidRequestError, q.add_column, object()) + def test_invalid_column_tuple(self): + User = self.classes.User + + s = create_session() + q = s.query(User) + assert_raises(sa_exc.InvalidRequestError, q.add_column, (1, 1)) + def test_distinct(self): """test that a distinct() call is not valid before 'clauseelement' conditions."""