MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / safe_merge

Method safe_merge

lib/sqlalchemy/sql/base.py:985–1007  ·  lib/sqlalchemy/sql/base.py::Options.safe_merge
(cls, other: "Options")

Source from the content-addressed store, hash-verified

983
984 @classmethod
985 def safe_merge(cls, other: class="st">"Options") -> Any:
986 d = other._state_dict()
987
988 class="cm"># only support a merge with another object of our class
989 class="cm"># and which does not have attrs that we don't. otherwise
990 class="cm"># we risk having state that might not be part of our cache
991 class="cm"># key strategy
992
993 if (
994 cls is not other.__class__
995 and other._cache_attrs
996 and set(other._cache_attrs).difference(cls._cache_attrs)
997 ):
998 raise TypeError(
999 class="st">"other element %r is not empty, is not of type %s, "
1000 class="st">"and contains attributes not covered here %r"
1001 % (
1002 other,
1003 cls,
1004 set(other._cache_attrs).difference(cls._cache_attrs),
1005 )
1006 )
1007 return cls + d
1008
1009 @classmethod
1010 def from_execution_options(

Callers 2

_create_orm_contextMethod · 0.80
test_options_mergeMethod · 0.80

Calls 2

_state_dictMethod · 0.80
differenceMethod · 0.45

Tested by 1

test_options_mergeMethod · 0.64