]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed adaptation of EXISTS clauses via any(), has(), etc.
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 26 Feb 2009 15:16:06 +0000 (15:16 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 26 Feb 2009 15:16:06 +0000 (15:16 +0000)
in conjunction with an aliased object on the left and
of_type() on the right.  [ticket:1325]

CHANGES
lib/sqlalchemy/orm/properties.py
test/orm/inheritance/query.py

diff --git a/CHANGES b/CHANGES
index 5848a679656d1f7d3d621e18c3e375cfe4f4beeb..f6fc99271b7776a5a2aa333082d3dc4ae789d544 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -51,6 +51,10 @@ CHANGES
         query(A).join(A.bs).filter(B.foo=='bar'), were erroneously
         adapting "B.foo" as though it were an "A".
     
+     - Fixed adaptation of EXISTS clauses via any(), has(), etc.
+       in conjunction with an aliased object on the left and 
+       of_type() on the right.  [ticket:1325]
+       
      - Added an attribute helper method ``set_committed_value`` in 
        sqlalchemy.orm.attributes.  Given an object, attribute name,
        and value, will set the value on the object as part of its
index 2a772dcac244a7d4a2b78da93b05fb8f21fdbea7..9c2268e01493e4b7d4ee7517d0ece379aee8b5fb 100644 (file)
@@ -472,7 +472,7 @@ class RelationProperty(StrategizedProperty):
             return op(self, *other, **kwargs)
 
         def of_type(self, cls):
-            return RelationProperty.Comparator(self.property, self.mapper, cls)
+            return RelationProperty.Comparator(self.property, self.mapper, cls, adapter=self.adapter)
 
         def in_(self, other):
             raise NotImplementedError("in_() not yet supported for relations.  For a "
@@ -511,7 +511,7 @@ class RelationProperty(StrategizedProperty):
                 source_selectable = self.__clause_element__()
             else:
                 source_selectable = None
-                
+            
             pj, sj, source, dest, secondary, target_adapter = \
                 self.property._create_joins(dest_polymorphic=True, dest_selectable=to_selectable, source_selectable=source_selectable)
 
index ca789f8338ea23237bfc595833bca29a64f201aa..0f5d982f1df100ed649c8d5726d6e4d0dde104d9 100644 (file)
@@ -280,6 +280,12 @@ def make_test(select_type):
                 sess.query(Company).filter(Company.employees.of_type(Engineer).any(Engineer.primary_language=='cobol')).one(),
                 c2
                 )
+            
+            calias = aliased(Company)
+            self.assertEquals(
+                sess.query(calias).filter(calias.employees.of_type(Engineer).any(Engineer.primary_language=='cobol')).one(),
+                c2
+            )
 
             self.assertEquals(
                 sess.query(Company).filter(Company.employees.of_type(Boss).any(Boss.golf_swing=='fore')).one(),