MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _adapt_inherited_property

Method _adapt_inherited_property

lib/sqlalchemy/orm/mapper.py:1990–2016  ·  view source on GitHub ↗
(self, key, prop, init)

Source from the content-addressed store, hash-verified

1988
1989 @util.preload_module("sqlalchemy.orm.descriptor_props")
1990 def _adapt_inherited_property(self, key, prop, init):
1991 descriptor_props = util.preloaded.orm_descriptor_props
1992
1993 if not self.concrete:
1994 self._configure_property(key, prop, init=False, setparent=False)
1995 elif key not in self._props:
1996 # determine if the class implements this attribute; if not,
1997 # or if it is implemented by the attribute that is handling the
1998 # given superclass-mapped property, then we need to report that we
1999 # can't use this at the instance level since we are a concrete
2000 # mapper and we don't map this. don't trip user-defined
2001 # descriptors that might have side effects when invoked.
2002 implementing_attribute = self.class_manager._get_class_attr_mro(
2003 key, prop
2004 )
2005 if implementing_attribute is prop or (
2006 isinstance(
2007 implementing_attribute, attributes.InstrumentedAttribute
2008 )
2009 and implementing_attribute._parententity is prop.parent
2010 ):
2011 self._configure_property(
2012 key,
2013 descriptor_props.ConcreteInheritedProperty(),
2014 init=init,
2015 setparent=True,
2016 )
2017
2018 @util.preload_module("sqlalchemy.orm.descriptor_props")
2019 def _configure_property(

Callers 3

_set_concrete_baseMethod · 0.95
_configure_propertiesMethod · 0.95
_configure_propertyMethod · 0.80

Calls 2

_configure_propertyMethod · 0.95
_get_class_attr_mroMethod · 0.80

Tested by

no test coverage detected