]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- add some logging to path_registry to help debug eager loading
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 24 Nov 2014 22:35:50 +0000 (17:35 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 24 Nov 2014 22:35:50 +0000 (17:35 -0500)
issues

lib/sqlalchemy/orm/path_registry.py
lib/sqlalchemy/orm/strategy_options.py

index f10a125a85f9d71d11eb484bb445ab22d8188d42..d4dbf29a0899a350fcb4bdabd637b07f53849d0d 100644 (file)
@@ -13,6 +13,9 @@ from .. import util
 from .. import exc
 from itertools import chain
 from .base import class_mapper
+import logging
+
+log = logging.getLogger(__name__)
 
 
 def _unreduce_path(path):
@@ -54,9 +57,11 @@ class PathRegistry(object):
             self.path == other.path
 
     def set(self, attributes, key, value):
+        log.debug("set '%s' on path '%s' to '%s'", key, self, value)
         attributes[(key, self.path)] = value
 
     def setdefault(self, attributes, key, value):
+        log.debug("setdefault '%s' on path '%s' to '%s'", key, self, value)
         attributes.setdefault((key, self.path), value)
 
     def get(self, attributes, key, value=None):
@@ -184,6 +189,11 @@ class PropRegistry(PathRegistry):
         self.parent = parent
         self.path = parent.path + (prop,)
 
+    def __str__(self):
+        return " -> ".join(
+            str(elem) for elem in self.path
+        )
+
     @util.memoized_property
     def has_entity(self):
         return hasattr(self.prop, "mapper")
index 4f986193e24de4fc8c50177e88045f63f8427a69..a4107202eb88eefa897aa29b3ecbaef41180fd2b 100644 (file)
@@ -176,6 +176,9 @@ class Load(Generative, MapperOption):
             path = path.entity_path
         return path
 
+    def __str__(self):
+        return "Load(strategy=%r)" % self.strategy
+
     def _coerce_strat(self, strategy):
         if strategy is not None:
             strategy = tuple(sorted(strategy.items()))