parse an attribute or wildcard argument to produce an :class:`._AbstractLoad` instance. This is used by the standalone loader strategy functions like ``joinedload()``, ``defer()``, etc. to produce :class:`_orm.Load` or :class:`._WildcardLoad` objects.
(
attr: _AttrType,
)
| 2364 | |
| 2365 | |
| 2366 | def _parse_attr_argument( |
| 2367 | attr: _AttrType, |
| 2368 | ) -> Tuple[InspectionAttr, _InternalEntityType[Any], MapperProperty[Any]]: |
| 2369 | """parse an attribute or wildcard argument to produce an |
| 2370 | :class:`._AbstractLoad` instance. |
| 2371 | |
| 2372 | This is used by the standalone loader strategy functions like |
| 2373 | ``joinedload()``, ``defer()``, etc. to produce :class:`_orm.Load` or |
| 2374 | :class:`._WildcardLoad` objects. |
| 2375 | |
| 2376 | """ |
| 2377 | try: |
| 2378 | # TODO: need to figure out this None thing being returned by |
| 2379 | # inspect(), it should not have None as an option in most cases |
| 2380 | # if at all |
| 2381 | insp: InspectionAttr = inspect(attr) # type: ignore |
| 2382 | except sa_exc.NoInspectionAvailable as err: |
| 2383 | raise sa_exc.ArgumentError( |
| 2384 | "expected ORM mapped attribute for loader strategy argument" |
| 2385 | ) from err |
| 2386 | |
| 2387 | lead_entity: _InternalEntityType[Any] |
| 2388 | |
| 2389 | if insp_is_mapper_property(insp): |
| 2390 | lead_entity = insp.parent |
| 2391 | prop = insp |
| 2392 | elif insp_is_attribute(insp): |
| 2393 | lead_entity = insp.parent |
| 2394 | prop = insp.prop |
| 2395 | else: |
| 2396 | raise sa_exc.ArgumentError( |
| 2397 | "expected ORM mapped attribute for loader strategy argument" |
| 2398 | ) |
| 2399 | |
| 2400 | return insp, lead_entity, prop |
| 2401 | |
| 2402 | |
| 2403 | def loader_unbound_fn(fn: _FN) -> _FN: |
no test coverage detected