]> git.donarmstrong.com Git - dak.git/commitdiff
Merge branch 'master' into dbtests
authorTorsten Werner <twerner@debian.org>
Tue, 18 Jan 2011 17:55:06 +0000 (18:55 +0100)
committerTorsten Werner <twerner@debian.org>
Tue, 18 Jan 2011 17:55:06 +0000 (18:55 +0100)
daklib/dbconn.py
tests/dbtest_timestamps.py

index 766efdb4a9e463f6b1b3837c3410037d2174a90c..6ea3aa398beaa1745795321e3d3d7bc3af2759f5 100755 (executable)
@@ -3020,7 +3020,11 @@ class DBConn(object):
                                  archive_type = self.tbl_location.c.type))
 
         mapper(Maintainer, self.tbl_maintainer,
-               properties = dict(maintainer_id = self.tbl_maintainer.c.id))
+               properties = dict(maintainer_id = self.tbl_maintainer.c.id,
+                   maintains_sources = relation(DBSource, backref='maintainer',
+                       primaryjoin=(self.tbl_maintainer.c.id==self.tbl_source.c.maintainer)),
+                   changed_sources = relation(DBSource, backref='changedby',
+                       primaryjoin=(self.tbl_maintainer.c.id==self.tbl_source.c.changedby))))
 
         mapper(NewComment, self.tbl_new_comments,
                properties = dict(comment_id = self.tbl_new_comments.c.id))
@@ -3056,19 +3060,15 @@ class DBConn(object):
                properties = dict(source_id = self.tbl_source.c.id,
                                  version = self.tbl_source.c.version,
                                  maintainer_id = self.tbl_source.c.maintainer,
-                                 maintainer = relation(Maintainer,
-                                                       primaryjoin=(self.tbl_source.c.maintainer==self.tbl_maintainer.c.id)),
                                  poolfile_id = self.tbl_source.c.file,
                                  poolfile = relation(PoolFile),
                                  fingerprint_id = self.tbl_source.c.sig_fpr,
                                  fingerprint = relation(Fingerprint),
                                  changedby_id = self.tbl_source.c.changedby,
-                                 changedby = relation(Maintainer,
-                                                      primaryjoin=(self.tbl_source.c.changedby==self.tbl_maintainer.c.id)),
                                  srcfiles = relation(DSCFile,
                                                      primaryjoin=(self.tbl_source.c.id==self.tbl_dsc_files.c.source)),
-                                 srcassociations = relation(SrcAssociation,
-                                                            primaryjoin=(self.tbl_source.c.id==self.tbl_src_associations.c.source)),
+                                 suites = relation(Suite, secondary=self.tbl_src_associations,
+                                     backref='sources'),
                                  srcuploaders = relation(SrcUploader)))
 
         mapper(SourceACL, self.tbl_source_acl,
index 98642c419624b3f25a923d0ed85c2c40a2db2775..1a53ae8665da5c9241370165bc5136c5926533a8 100755 (executable)
@@ -4,6 +4,7 @@ from db_test import DBDakTestCase
 
 from daklib.dbconn import DBConn, Uid
 
+from sqlalchemy import func
 import time
 import unittest
 
@@ -16,10 +17,13 @@ class TimestampTestCase(DBDakTestCase):
     """
 
     def now(self):
+        "returns the current time at the db server"
+
+        # we fetch a fresh session each time to avoid caching
         local_session = DBConn().session()
-        query = local_session.query('now').from_statement('select now() as now')
+        current_time = local_session.query(func.now()).scalar()
         local_session.close()
-        return query.first().now
+        return current_time
 
     def sleep(self):
         time.sleep(0.001)