]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
updating the cycles test
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 22 Oct 2006 05:45:43 +0000 (05:45 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 22 Oct 2006 05:45:43 +0000 (05:45 +0000)
lib/sqlalchemy/orm/dependency.py
test/orm/cycles.py

index 898d03eb68bbd470531a693bcee0e61ad97f6e20..8bf5a489d9b389ef0a5941fde65d43c618e3f3bf 100644 (file)
@@ -155,8 +155,6 @@ class OneToManyDP(DependencyProcessor):
             # head object is being deleted, and we manage its list of child objects
             # the child objects have to have their foreign key to the parent set to NULL
             if self.post_update:
-                # TODO: post_update instructions should be established in this step as well
-                # (and executed in the regular traversal)
                 pass
             elif self.cascade.delete_orphan:
                 for obj in deplist:
@@ -232,8 +230,6 @@ class ManyToOneDP(DependencyProcessor):
                         
     def preprocess_dependencies(self, task, deplist, uowcommit, delete = False):
         #print self.mapper.mapped_table.name + " " + self.key + " " + repr(len(deplist)) + " PRE process_dep isdelete " + repr(delete) + " direction " + repr(self.direction)
-        # TODO: post_update instructions should be established in this step as well
-        # (and executed in the regular traversal)
         if self.post_update:
             return
         if delete:
@@ -306,8 +302,7 @@ class ManyToManyDP(DependencyProcessor):
                     secondary_delete.append(associationrow)
         if len(secondary_delete):
             secondary_delete.sort()
-            # TODO: precompile the delete/insert queries and store them as instance variables
-            # on the PropertyLoader
+            # TODO: precompile the delete/insert queries?
             statement = self.secondary.delete(sql.and_(*[c == sql.bindparam(c.key) for c in self.secondary.c if c.key in associationrow]))
             connection.execute(statement, secondary_delete)
         if len(secondary_insert):
index 387bd18441bb46e1b2fee68057fb8fe06b9cb906..b335bd311d5adc73e9d63b09b625193eb72b1e2c 100644 (file)
@@ -106,25 +106,23 @@ class BiDirectionalOneToManyTest(AssertMixin):
         )
         t2 = Table('t2', metadata,
             Column('c1', Integer, Sequence('t2c1_id_seq', optional=True), primary_key=True),
-            Column('c2', Integer)
+            Column('c2', Integer, ForeignKey('t1.c1', use_alter=True, name='t1c1_fk'))
         )
         metadata.create_all()
-        t2.c.c2.append_foreign_key(ForeignKey('t1.c1'))
     def tearDownAll(self):
-        t1.drop()
-        t2.drop()
-        #metadata.drop_all()
+        metadata.drop_all()
     def tearDown(self):
         clear_mappers()
     def testcycle(self):
         class C1(object):pass
         class C2(object):pass
         
-        m2 = mapper(C2, t2)
+        m2 = mapper(C2, t2, properties={
+            'c1s': relation(C1, primaryjoin=t2.c.c1==t1.c.c2, uselist=True)
+        })
         m1 = mapper(C1, t1, properties = {
-            'c2s' : relation(m2, primaryjoin=t1.c.c2==t2.c.c1, uselist=True)
+            'c2s' : relation(C2, primaryjoin=t1.c.c1==t2.c.c2, uselist=True)
         })
-        m2.add_property('c1s', relation(m1, primaryjoin=t2.c.c2==t1.c.c1, uselist=True))
         a = C1()
         b = C2()
         c = C1()
@@ -170,12 +168,13 @@ class BiDirectionalOneToManyTest2(AssertMixin):
             def __init__(self, data=None):
                 self.data = data
                 
-        m2 = mapper(C2, t2)
+        m2 = mapper(C2, t2, properties={
+            'c1s': relation(C1, primaryjoin=t2.c.c1==t1.c.c2, uselist=True)
+        })
         m1 = mapper(C1, t1, properties = {
-            'c2s' : relation(m2, primaryjoin=t1.c.c2==t2.c.c1, uselist=True),
+            'c2s' : relation(C2, primaryjoin=t1.c.c1==t2.c.c2, uselist=True),
             'data' : relation(mapper(C1Data, t3))
         })
-        m2.add_property('c1s', relation(m1, primaryjoin=t2.c.c2==t1.c.c1, uselist=True))
         
         a = C1()
         b = C2()