diff options
-rw-r--r-- | lib/sqlalchemy/sql/visitors.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/visitors.py b/lib/sqlalchemy/sql/visitors.py index d9ad04fc0..5bbbb40e2 100644 --- a/lib/sqlalchemy/sql/visitors.py +++ b/lib/sqlalchemy/sql/visitors.py @@ -26,6 +26,7 @@ http://techspot.zzzeek.org/2008/01/23/expression-transformations/ from collections import deque from .. import util import operator +import weakref from .. import exc __all__ = ['VisitableType', 'Visitable', 'ClauseVisitor', @@ -306,8 +307,9 @@ def replacement_traverse(obj, opts, replace): else: if elem not in cloned: cloned[elem] = newelem = elem._clone() - newelem._copy_internals(clone=clone, **kw) + newelem._copy_internals(clone=weak_clone, **kw) return cloned[elem] + weak_clone = weakref.proxy(clone) if obj is not None: obj = clone(obj, **opts) |