Commits

Mike Bayer committed 6f82595

updating the cycles test

  • Participants
  • Parent commits 8db5f17

Comments (0)

Files changed (2)

lib/sqlalchemy/orm/dependency.py

             # 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:
                         
     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:
                     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):

test/orm/cycles.py

         )
         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()
             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()