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

Method safe_merge

lib/sqlalchemy/sql/base.py:973–995  ·  view source on GitHub ↗
(cls, other: "Options")

Source from the content-addressed store, hash-verified

971
972 @classmethod
973 def safe_merge(cls, other: "Options") -> Any:
974 d = other._state_dict()
975
976 # only support a merge with another object of our class
977 # and which does not have attrs that we don't. otherwise
978 # we risk having state that might not be part of our cache
979 # key strategy
980
981 if (
982 cls is not other.__class__
983 and other._cache_attrs
984 and set(other._cache_attrs).difference(cls._cache_attrs)
985 ):
986 raise TypeError(
987 "other element %r is not empty, is not of type %s, "
988 "and contains attributes not covered here %r"
989 % (
990 other,
991 cls,
992 set(other._cache_attrs).difference(cls._cache_attrs),
993 )
994 )
995 return cls + d
996
997 @classmethod
998 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