[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master] Carefully add a backref from PoolFile to Location.



Using lazy='dynamic' makes sure that property Location.files is not a very huge
list but a query object that can be iterated or .filter()-ed.

Signed-off-by: Torsten Werner <twerner@debian.org>
---
 daklib/dbconn.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/daklib/dbconn.py b/daklib/dbconn.py
index 93ec117..75e56cd 100755
--- a/daklib/dbconn.py
+++ b/daklib/dbconn.py
@@ -2945,7 +2945,11 @@ class DBConn(object):
                properties = dict(file_id = self.tbl_files.c.id,
                                  filesize = self.tbl_files.c.size,
                                  location_id = self.tbl_files.c.location,
-                                 location = relation(Location)))
+                                 location = relation(Location,
+                                     # using lazy='dynamic' in the back
+                                     # reference because we have A LOT of
+                                     # files in one location
+                                     backref=backref('files', lazy='dynamic'))))
 
         mapper(Fingerprint, self.tbl_fingerprint,
                properties = dict(fingerprint_id = self.tbl_fingerprint.c.id,
-- 
1.5.6.5



Reply to: