]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
backref() func will also honor lazy=True/False
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 7 Mar 2006 03:16:10 +0000 (03:16 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 7 Mar 2006 03:16:10 +0000 (03:16 +0000)
lib/sqlalchemy/mapping/properties.py

index 6ca0a7641b98c818ae857b00ea44462e5fbb9946..ba77d3f4cf4e1345b1ce629f3c6ada4b7272c041 100644 (file)
@@ -822,7 +822,12 @@ class BackRef(object):
             else:
                 pj = prop.primaryjoin
                 sj = None
-            relation = LazyLoader(prop.parent, prop.secondary, pj, sj, backref=prop.key, is_backref=True, **self.kwargs)
+            lazy = self.kwargs.pop('lazy', True)
+            if lazy:
+                cls = LazyLoader
+            else:
+                cls = EagerLoader
+            relation = cls(prop.parent, prop.secondary, pj, sj, backref=prop.key, is_backref=True, **self.kwargs)
             prop.mapper.add_property(self.key, relation);
         else:
             # else set one of us as the "backreference"