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

Method _set_polymorphic_identity

lib/sqlalchemy/orm/mapper.py:1987–2009  ·  view source on GitHub ↗
(state)

Source from the content-addressed store, hash-verified

1985 if setter:
1986
1987 def _set_polymorphic_identity(state):
1988 dict_ = state.dict
1989 # TODO: what happens if polymorphic_on column attribute name
1990 # does not match .key?
1991
1992 polymorphic_identity = (
1993 state.manager.mapper.polymorphic_identity
1994 )
1995 if (
1996 polymorphic_identity is None
1997 and state.manager.mapper.polymorphic_abstract
1998 ):
1999 raise sa_exc.InvalidRequestError(
2000 f"Can't instantiate class for {state.manager.mapper}; "
2001 "mapper is marked polymorphic_abstract=True"
2002 )
2003
2004 state.get_impl(polymorphic_key).set(
2005 state,
2006 dict_,
2007 polymorphic_identity,
2008 None,
2009 )
2010
2011 self._polymorphic_attr_key = polymorphic_key
2012

Callers 1

_event_on_initFunction · 0.80

Calls 2

setMethod · 0.45
get_implMethod · 0.45

Tested by

no test coverage detected