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

Method __init__

lib/sqlalchemy/orm/context.py:2865–2922  ·  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

2863 expr: Bundle
2864
2865 def __init__(
2866 self,
2867 compile_state,
2868 expr,
2869 entities_collection,
2870 is_current_entities,
2871 setup_entities=True,
2872 parent_bundle=None,
2873 ):
2874 compile_state._has_orm_entities = True
2875
2876 expr = expr._annotations["bundle"]
2877 if parent_bundle:
2878 parent_bundle._entities.append(self)
2879 else:
2880 entities_collection.append(self)
2881
2882 if isinstance(
2883 expr, (attributes.QueryableAttribute, interfaces.PropComparator)
2884 ):
2885 bundle = expr.__clause_element__()
2886 else:
2887 bundle = expr
2888
2889 self.bundle = self.expr = bundle
2890 self.type = type(bundle)
2891 self._label_name = bundle.name
2892 self._entities = []
2893
2894 if setup_entities:
2895 for expr in bundle.exprs:
2896 if "bundle" in expr._annotations:
2897 _BundleEntity(
2898 compile_state,
2899 expr,
2900 entities_collection,
2901 is_current_entities,
2902 parent_bundle=self,
2903 )
2904 elif isinstance(expr, Bundle):
2905 _BundleEntity(
2906 compile_state,
2907 expr,
2908 entities_collection,
2909 is_current_entities,
2910 parent_bundle=self,
2911 )
2912 else:
2913 _ORMColumnEntity._for_columns(
2914 compile_state,
2915 [expr],
2916 entities_collection,
2917 None,
2918 is_current_entities,
2919 parent_bundle=self,
2920 )
2921
2922 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