]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- added a warning when a relation() is added to an inheriting mapper that is present...
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 9 Dec 2007 17:26:16 +0000 (17:26 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 9 Dec 2007 17:26:16 +0000 (17:26 +0000)
- found an uncovered line in uow, was "covered" by one particular breaking test

lib/sqlalchemy/orm/properties.py
lib/sqlalchemy/orm/unitofwork.py
test/orm/inheritance/abc_inheritance.py

index 775bcd0a55b6aabbd09629ff5c3b29b97968bceb..f0cae49d80643847903bf35cbd2c6c77808238ed 100644 (file)
@@ -399,6 +399,10 @@ class PropertyLoader(StrategizedProperty):
         # ensure the "select_mapper", if different from the regular target mapper, is compiled.
         self.mapper.get_select_mapper()._check_compile()
 
+        for inheriting in self.parent.iterate_to_root():
+            if inheriting is not self.parent and inheriting.get_property(self.key, raiseerr=False):
+                warnings.warn(RuntimeWarning("Warning: relation '%s' on mapper '%s' supercedes the same relation on inherited mapper '%s'; this can cause dependency issues during flush" % (self.key, self.parent, inheriting)))
+
         if self.association is not None:
             if isinstance(self.association, type):
                 self.association = mapper.class_mapper(self.association, entity_name=self.entity_name, compile=False)._check_compile()
index a6bf8df901ddac06beef19d4d11b29deab71cbbf..26ac3703ebbdec5727565040629cfcb8a756ee78 100644 (file)
@@ -734,7 +734,8 @@ class UOWTask(object):
                                 else:
                                     get_dependency_task(whosdep[0], dep).append(whosdep[1], isdelete=isdelete)
                             else:
-                                get_dependency_task(state, dep).append(obj, isdelete=isdelete)
+                                # TODO: no test coverage here
+                                get_dependency_task(state, dep).append(state, isdelete=isdelete)
 
         head = topological.sort_as_tree(tuples, allobjects)
         
index 3b35b3713de302f050b8ea5549515467ab2c259b..ecd7d0f291dd9530b67efbab08792611ceb69391 100644 (file)
@@ -110,7 +110,9 @@ def produce_test(parent, child, direction):
             somea = A('somea')
             someb = B('someb')
             somec = C('somec')
-            print "APPENDING", parent.__class__.__name__ , "TO", child.__class__.__name__
+            
+            #print "APPENDING", parent.__class__.__name__ , "TO", child.__class__.__name__
+            
             sess.save(parent_obj)
             parent_obj.collection.append(child_obj)
             if direction == ONETOMANY: