From: Torsten Werner Date: Wed, 23 Mar 2011 11:09:11 +0000 (+0100) Subject: Metadata: add cascading to mapper configuration. X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=c1ac00acb270e1cb17704aa1d1e85103e002a683;p=dak.git Metadata: add cascading to mapper configuration. Signed-off-by: Torsten Werner --- diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 25fd9c6e..6782c081 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -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) diff --git a/tests/dbtest_metadata.py b/tests/dbtest_metadata.py index dff1b05f..1b698b85 100755 --- a/tests/dbtest_metadata.py +++ b/tests/dbtest_metadata.py @@ -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()