From: Mike Bayer Date: Wed, 18 Jul 2007 19:06:10 +0000 (+0000) Subject: - merged fix of PG identifier length from 68 to 63 [ticket:571] X-Git-Tag: rel_0_4_6~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f22b03f9ae931bb2c5213d18a525496d2ae0bbf1;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - merged fix of PG identifier length from 68 to 63 [ticket:571] - merged r2958, commutativity for _BinaryExpression.compare --- diff --git a/CHANGES b/CHANGES index e2d6010bf3..235e77644a 100644 --- a/CHANGES +++ b/CHANGES @@ -131,6 +131,19 @@ from SelectResults isn't present anymore, need to use join(). - postgres - Added PGArray datatype for using postgres array datatypes + +0.3.10 +- sql + - got connection-bound metadata to work with implicit execution + - foreign key specs can have any chararcter in their identifiers + [ticket:667] + - added commutativity-awareness to binary clause comparisons to + each other, improves ORM lazy load optimization [ticket:664] +- orm + - cleanup to connection-bound sessions, SessionTransaction +- postgres + - fixed max identifier length (63) [ticket:571] + 0.3.9 - general - better error message for NoSuchColumnError [ticket:607] diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 3c37ac0071..469614fbb3 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -223,7 +223,7 @@ class PGDialect(ansisql.ANSIDialect): return PGExecutionContext(self, *args, **kwargs) def max_identifier_length(self): - return 68 + return 63 def type_descriptor(self, typeobj): return sqltypes.adapt_type(typeobj, colspecs) diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py index e044729e08..1129629ca6 100644 --- a/lib/sqlalchemy/sql.py +++ b/lib/sqlalchemy/sql.py @@ -2127,7 +2127,13 @@ class _BinaryExpression(ColumnElement): return ( isinstance(other, _BinaryExpression) and self.operator == other.operator and - self.left.compare(other.left) and self.right.compare(other.right) + ( + self.left.compare(other.left) and self.right.compare(other.right) + or ( + self.operator in ['=', '!=', '+', '*'] and + self.left.compare(other.right) and self.right.compare(other.left) + ) + ) ) def self_group(self, against=None): diff --git a/test/orm/lazy_relations.py b/test/orm/lazy_relations.py index 5accb74713..e9d77e09c6 100644 --- a/test/orm/lazy_relations.py +++ b/test/orm/lazy_relations.py @@ -230,23 +230,29 @@ class LazyTest(QueryTest): def test_uses_get(self): """test that a simple many-to-one lazyload optimizes to use query.get().""" - mapper(Address, addresses, properties = dict( - user = relation(mapper(User, users), lazy=True) - )) + for pj in ( + None, + users.c.id==addresses.c.user_id, + addresses.c.user_id==users.c.id + ): + mapper(Address, addresses, properties = dict( + user = relation(mapper(User, users), lazy=True, primaryjoin=pj) + )) - sess = create_session() + sess = create_session() - # load address - a1 = sess.query(Address).filter_by(email_address="ed@wood.com").one() + # load address + a1 = sess.query(Address).filter_by(email_address="ed@wood.com").one() - # load user that is attached to the address - u1 = sess.query(User).get(8) + # load user that is attached to the address + u1 = sess.query(User).get(8) + + def go(): + # lazy load of a1.user should get it from the session + assert a1.user is u1 + self.assert_sql_count(testbase.db, go, 0) + clear_mappers() - def go(): - # lazy load of a1.user should get it from the session - assert a1.user is u1 - self.assert_sql_count(testbase.db, go, 0) - def test_many_to_one(self): mapper(Address, addresses, properties = dict( user = relation(mapper(User, users), lazy=True)