]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
also check for primaryjoin/secondaryjoin that equates to False, [ticket:1087]
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 22 Dec 2008 17:51:25 +0000 (17:51 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 22 Dec 2008 17:51:25 +0000 (17:51 +0000)
CHANGES
lib/sqlalchemy/orm/properties.py
test/orm/relationships.py

diff --git a/CHANGES b/CHANGES
index 323698b8e97c17a0754d354ef79823168a0e6d31..c5571d5c391fb61e1addc8528ebb21710f5a073b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -90,7 +90,7 @@ CHANGES
     - Extra checks added to ensure explicit 
       primaryjoin/secondaryjoin are ClauseElement 
       instances, to prevent more confusing errors later 
-      on.
+      on. [ticket:1087]
 
     - Improved mapper() check for non-class classes.
       [ticket:1236]
index 5bd3c0842cef49a77a011a833e1db67528fd6755..bf9bda366f12f6591e891efb5fc9a3b3595b375d 100644 (file)
@@ -604,7 +604,7 @@ class RelationProperty(StrategizedProperty):
         # interact with Query in the same way as the original Table-bound Column objects
         for attr in ('primaryjoin', 'secondaryjoin'):
             val = getattr(self, attr)
-            if val:
+            if val is not None:
                 util.assert_arg_type(val, sql.ClauseElement, attr)
                 setattr(self, attr, _orm_deannotate(val))
         
index 181ed375cefd832943740f32f26e1f0b4d6c3a4f..f022f433b967142fd4a2ccfe4a1ce97b429cca88 100644 (file)
@@ -666,7 +666,21 @@ class JoinConditionErrorTest(testing.TestBase):
             c2 = relation(C1, primaryjoin=C1.id)
         
         self.assertRaises(sa.exc.ArgumentError, compile_mappers)
-            
+
+    def test_clauseelement_pj_false(self):
+        from sqlalchemy.ext.declarative import declarative_base
+        Base = declarative_base()
+        class C1(Base):
+            __tablename__ = 'c1'
+            id = Column('id', Integer, primary_key=True)
+        class C2(Base):
+            __tablename__ = 'c2'
+            id = Column('id', Integer, primary_key=True)
+            c1id = Column('c1id', Integer, ForeignKey('c1.id'))
+            c2 = relation(C1, primaryjoin="x"=="y")
+
+        self.assertRaises(sa.exc.ArgumentError, compile_mappers)
+        
     
     def test_fk_error_raised(self):
         m = MetaData()