]> git.decadent.org.uk Git - dak.git/commitdiff
Metadata: add cascading to mapper configuration.
authorTorsten Werner <twerner@debian.org>
Wed, 23 Mar 2011 11:09:11 +0000 (12:09 +0100)
committerTorsten Werner <twerner@debian.org>
Wed, 23 Mar 2011 11:09:11 +0000 (12:09 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
daklib/dbconn.py
tests/dbtest_metadata.py

index 25fd9c6ee578fa215829afea7005e9c78a3b2755..6782c081145944e57c22a1bf718872e00c7106c9 100755 (executable)
@@ -2992,7 +2992,7 @@ class DBConn(object):
                                      backref=backref('binaries', lazy='dynamic')),
                                  extra_sources = relation(DBSource, secondary=self.tbl_extra_src_references,
                                      backref=backref('extra_binary_references', lazy='dynamic')),
-                                 key = relation(BinaryMetadata,
+                                 key = relation(BinaryMetadata, cascade='all',
                                      collection_class=attribute_mapped_collection('key'))),
                 extension = validator)
 
@@ -3164,7 +3164,7 @@ class DBConn(object):
                                  suites = relation(Suite, secondary=self.tbl_src_associations,
                                      backref=backref('sources', lazy='dynamic')),
                                  srcuploaders = relation(SrcUploader),
-                                 key = relation(SourceMetadata,
+                                 key = relation(SourceMetadata, cascade='all',
                                      collection_class=attribute_mapped_collection('key'))),
                extension = validator)
 
index dff1b05f239505ea80125310391ef74333afe7ea..1b698b85e85148a609ff6643cac77809a9badbc9 100755 (executable)
@@ -76,5 +76,18 @@ class MetadataTestCase(DBDakTestCase):
         self.assertEqual('http://debian.org', self.src_hello.metadata[self.homepage])
         self.assertTrue(self.depends not in self.src_hello.metadata)
 
+    def test_delete(self):
+        '''
+        Tests the delete / cascading behaviour.
+        '''
+        self.setup_metadata()
+        self.session.delete(self.bin_hello)
+        # Remove associated binaries because we have no cascading rule for
+        # them.
+        for binary in self.src_hello.binaries:
+            self.session.delete(binary)
+        self.session.delete(self.src_hello)
+        self.session.flush()
+
 if __name__ == '__main__':
     unittest.main()