diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-02-20 15:14:08 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-02-20 15:14:08 -0500 |
commit | 305ea84004fe604f461cd3c9438fbc84e3d790b2 (patch) | |
tree | c0bd81cf661d99f289cd26fa7b8730cccb3a5da9 /lib | |
parent | 4f63e2497020681a4f2aa5d4a28495ded008d2b2 (diff) | |
download | sqlalchemy-305ea84004fe604f461cd3c9438fbc84e3d790b2.tar.gz |
- Fixed bugs in ORM object comparisons where comparison of
many-to-one ``!= None`` would fail if the source were an aliased
class, or if the query needed to apply special aliasing to the
expression due to aliased joins or polymorphic querying; also fixed
bug in the case where comparing a many-to-one to an object state
would fail if the query needed to apply special aliasing
due to aliased joins or polymorphic querying.
fixes #3310
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sqlalchemy/orm/relationships.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py index 969b231ec..77a73e1f1 100644 --- a/lib/sqlalchemy/orm/relationships.py +++ b/lib/sqlalchemy/orm/relationships.py @@ -1291,8 +1291,9 @@ class RelationshipProperty(StrategizedProperty): """ if isinstance(other, (util.NoneType, expression.Null)): if self.property.direction == MANYTOONE: - return sql.or_(*[x != None for x in - self.property._calculated_foreign_keys]) + return _orm_annotate(~self.property._optimized_compare( + None, adapt_source=self.adapter)) + else: return self._criterion_exists() elif self.property.uselist: @@ -1301,7 +1302,7 @@ class RelationshipProperty(StrategizedProperty): " to an object or collection; use " "contains() to test for membership.") else: - return self.__negated_contains_or_equals(other) + return _orm_annotate(self.__negated_contains_or_equals(other)) @util.memoized_property def property(self): |