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

Method _clone

lib/sqlalchemy/sql/elements.py:424–451  ·  view source on GitHub ↗

Create a shallow copy of this ClauseElement. This method may be used by a generative API. Its also used as part of the "deep" copy afforded by a traversal that combines the _copy_internals() method.

(self, **kw: Any)

Source from the content-addressed store, hash-verified

422 return dialect.statement_compiler(dialect, self) # type: ignore
423
424 def _clone(self, **kw: Any) -> Self:
425 """Create a shallow copy of this ClauseElement.
426
427 This method may be used by a generative API. Its also used as
428 part of the "deep" copy afforded by a traversal that combines
429 the _copy_internals() method.
430
431 """
432
433 skip = self._memoized_keys
434 c = self.__class__.__new__(self.__class__)
435
436 if skip:
437 # ensure this iteration remains atomic
438 c.__dict__ = {
439 k: v for k, v in self.__dict__.copy().items() if k not in skip
440 }
441 else:
442 c.__dict__ = self.__dict__.copy()
443
444 # this is a marker that helps to "equate" clauses to each other
445 # when a Select returns its list of FROM clauses. the cloning
446 # process leaves around a lot of remnants of the previous clause
447 # typically in the form of column expressions still attached to the
448 # old table.
449 cc = self._is_clone_of
450 c._is_clone_of = cc if cc is not None else self
451 return c
452
453 def _negate_in_binary(self, negated_op, original_op):
454 """a hook to allow the right side of a binary expression to respond

Callers

nothing calls this directly

Calls 3

__new__Method · 0.45
itemsMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected