From 4f5aa12547264fb6a2e2f3af58d02ff09949d302 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 9 Dec 2007 17:26:16 +0000 Subject: [PATCH] - added a warning when a relation() is added to an inheriting mapper that is present on a super-mapper; multiple DependencyProcessors are not expected during the flush process - found an uncovered line in uow, was "covered" by one particular breaking test --- lib/sqlalchemy/orm/properties.py | 4 ++++ lib/sqlalchemy/orm/unitofwork.py | 3 ++- test/orm/inheritance/abc_inheritance.py | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py index 775bcd0a55..f0cae49d80 100644 --- a/lib/sqlalchemy/orm/properties.py +++ b/lib/sqlalchemy/orm/properties.py @@ -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() diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py index a6bf8df901..26ac3703eb 100644 --- a/lib/sqlalchemy/orm/unitofwork.py +++ b/lib/sqlalchemy/orm/unitofwork.py @@ -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) diff --git a/test/orm/inheritance/abc_inheritance.py b/test/orm/inheritance/abc_inheritance.py index 3b35b3713d..ecd7d0f291 100644 --- a/test/orm/inheritance/abc_inheritance.py +++ b/test/orm/inheritance/abc_inheritance.py @@ -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: -- 2.47.3