From: Mike Bayer Date: Sun, 22 Oct 2006 05:45:43 +0000 (+0000) Subject: updating the cycles test X-Git-Tag: rel_0_3_0~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a610264fe9af286e0f938ce5e3cb859b997ee7e5;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git updating the cycles test --- diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py index 898d03eb68..8bf5a489d9 100644 --- a/lib/sqlalchemy/orm/dependency.py +++ b/lib/sqlalchemy/orm/dependency.py @@ -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): diff --git a/test/orm/cycles.py b/test/orm/cycles.py index 387bd18441..b335bd311d 100644 --- a/test/orm/cycles.py +++ b/test/orm/cycles.py @@ -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()