MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / _clone

Method _clone

lib/sqlalchemy/sql/elements.py:2143–2158  ·  view source on GitHub ↗
(self, maintain_key: bool = False, **kw: Any)

Source from the content-addressed store, hash-verified

2141 return c
2142
2143 def _clone(self, maintain_key: bool = False, **kw: Any) -> Self:
2144 c = ClauseElement._clone(self, **kw)
2145 # ensure all the BindParameter objects stay in cloned set.
2146 # in #7823, we changed "clone" so that a clone only keeps a reference
2147 # to the "original" element, since for column correspondence, that's
2148 # all we need. However, for BindParam, _cloned_set is used by
2149 # the "cache key bind match" lookup, which means if any of those
2150 # interim BindParameter objects became part of a cache key in the
2151 # cache, we need it. So here, make sure all clones keep carrying
2152 # forward.
2153 c._cloned_set.update(self._cloned_set)
2154 if not maintain_key and self.unique:
2155 c.key = _anonymous_label.safe_construct(
2156 id(c), c._orig_key or "param", sanitize_key=True
2157 )
2158 return c
2159
2160 def _gen_cache_key(self, anon_map, bindparams):
2161 _gen_cache_ok = self.__class__.__dict__.get("inherit_cache", False)

Callers 4

_with_valueMethod · 0.95
_negate_in_binaryMethod · 0.95

Calls 3

safe_constructMethod · 0.80
_cloneMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected