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

Method __init__

lib/sqlalchemy/orm/attributes.py:197–233  ·  view source on GitHub ↗
(
        self,
        class_: _ExternalEntityType[_O],
        key: str,
        parententity: _InternalEntityType[_O],
        comparator: interfaces.PropComparator[_T_co],
        impl: Optional[AttributeImpl] = None,
        of_type: Optional[_InternalEntityType[Any]] = None,
        extra_criteria: Tuple[ColumnElement[bool], ...] = (),
    )

Source from the content-addressed store, hash-verified

195 __visit_name__ = "orm_instrumented_attribute"
196
197 def __init__(
198 self,
199 class_: _ExternalEntityType[_O],
200 key: str,
201 parententity: _InternalEntityType[_O],
202 comparator: interfaces.PropComparator[_T_co],
203 impl: Optional[AttributeImpl] = None,
204 of_type: Optional[_InternalEntityType[Any]] = None,
205 extra_criteria: Tuple[ColumnElement[bool], ...] = (),
206 ):
207 self.class_ = class_
208 self.key = key
209
210 self._parententity = self.parent = parententity
211
212 # this attribute is non-None after mappers are set up, however in the
213 # interim class manager setup, there's a check for None to see if it
214 # needs to be populated, so we assign None here leaving the attribute
215 # in a temporarily not-type-correct state
216 self.impl = impl # type: ignore
217
218 assert comparator is not None
219 self.comparator = comparator
220 self._of_type = of_type
221 self._extra_criteria = extra_criteria
222 self._doc = None
223
224 manager = opt_manager_of_class(class_)
225 # manager is None in the case of AliasedClass
226 if manager:
227 # propagate existing event listeners from
228 # immediate superclass
229 for base in manager._bases:
230 if key in base:
231 self.dispatch._update(base[key].dispatch)
232 if base[key].dispatch._active_history:
233 self.dispatch._active_history = True # type: ignore
234
235 _cache_key_traversal = [
236 ("key", visitors.ExtendedInternalTraversal.dp_string),

Callers

nothing calls this directly

Calls 2

opt_manager_of_classFunction · 0.85
_updateMethod · 0.45

Tested by

no test coverage detected