MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / __init__

Method __init__

lib/sqlalchemy/orm/context.py:3006–3063  ·  view source on GitHub ↗
(
        self,
        compile_state,
        expr,
        entities_collection,
        is_current_entities,
        setup_entities=True,
        parent_bundle=None,
    )

Source from the content-addressed store, hash-verified

3004 expr: Bundle
3005
3006 def __init__(
3007 self,
3008 compile_state,
3009 expr,
3010 entities_collection,
3011 is_current_entities,
3012 setup_entities=True,
3013 parent_bundle=None,
3014 ):
3015 compile_state._has_orm_entities = True
3016
3017 expr = expr._annotations["bundle"]
3018 if parent_bundle:
3019 parent_bundle._entities.append(self)
3020 else:
3021 entities_collection.append(self)
3022
3023 if isinstance(
3024 expr, (attributes.QueryableAttribute, interfaces.PropComparator)
3025 ):
3026 bundle = expr.__clause_element__()
3027 else:
3028 bundle = expr
3029
3030 self.bundle = self.expr = bundle
3031 self.type = type(bundle)
3032 self._label_name = bundle.name
3033 self._entities = []
3034
3035 if setup_entities:
3036 for expr in bundle.exprs:
3037 if "bundle" in expr._annotations:
3038 _BundleEntity(
3039 compile_state,
3040 expr,
3041 entities_collection,
3042 is_current_entities,
3043 parent_bundle=self,
3044 )
3045 elif isinstance(expr, Bundle):
3046 _BundleEntity(
3047 compile_state,
3048 expr,
3049 entities_collection,
3050 is_current_entities,
3051 parent_bundle=self,
3052 )
3053 else:
3054 _ORMColumnEntity._for_columns(
3055 compile_state,
3056 [expr],
3057 entities_collection,
3058 None,
3059 is_current_entities,
3060 parent_bundle=self,
3061 )
3062
3063 self.supports_single_entity = self.bundle.single_entity

Callers

nothing calls this directly

Calls 4

_BundleEntityClass · 0.85
_for_columnsMethod · 0.80
appendMethod · 0.45
__clause_element__Method · 0.45

Tested by

no test coverage detected