MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _clone

Method _clone

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

Source from the content-addressed store, hash-verified

2225 return c
2226
2227 def _clone(self, maintain_key: bool = False, **kw: Any) -> Self:
2228 c: Self = ClauseElement._clone(self, **kw)
2229 # ensure all the BindParameter objects stay in cloned set.
2230 # in #7823, we changed "clone" so that a clone only keeps a reference
2231 # to the "original" element, since for column correspondence, that's
2232 # all we need. However, for BindParam, _cloned_set is used by
2233 # the "cache key bind match" lookup, which means if any of those
2234 # interim BindParameter objects became part of a cache key in the
2235 # cache, we need it. So here, make sure all clones keep carrying
2236 # forward.
2237 c._cloned_set.update(self._cloned_set)
2238 if not maintain_key and self.unique:
2239 c.key, c._anon_map_key = _anonymous_label.safe_construct_with_key(
2240 id(c), c._orig_key or "param", sanitize_key=True
2241 )
2242 return c
2243
2244 def _gen_cache_key(self, anon_map, bindparams):
2245 _gen_cache_ok = self.__class__.__dict__.get("inherit_cache", False)

Callers 2

_with_valueMethod · 0.95
_negate_in_binaryMethod · 0.95

Calls 3

_cloneMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected