(
self,
compile_state,
column,
entities_collection,
parententity,
raw_column_index,
is_current_entities,
parent_bundle=None,
)
| 3329 | ) |
| 3330 | |
| 3331 | def __init__( |
| 3332 | self, |
| 3333 | compile_state, |
| 3334 | column, |
| 3335 | entities_collection, |
| 3336 | parententity, |
| 3337 | raw_column_index, |
| 3338 | is_current_entities, |
| 3339 | parent_bundle=None, |
| 3340 | ): |
| 3341 | annotations = column._annotations |
| 3342 | |
| 3343 | _entity = parententity |
| 3344 | |
| 3345 | # an AliasedClass won't have proxy_key in the annotations for |
| 3346 | # a column if it was acquired using the class' adapter directly, |
| 3347 | # such as using AliasedInsp._adapt_element(). this occurs |
| 3348 | # within internal loaders. |
| 3349 | |
| 3350 | orm_key = annotations.get("proxy_key", None) |
| 3351 | proxy_owner = annotations.get("proxy_owner", _entity) |
| 3352 | if orm_key: |
| 3353 | self.expr = getattr(proxy_owner.entity, orm_key) |
| 3354 | self.translate_raw_column = False |
| 3355 | else: |
| 3356 | # if orm_key is not present, that means this is an ad-hoc |
| 3357 | # SQL ColumnElement, like a CASE() or other expression. |
| 3358 | # include this column position from the invoked statement |
| 3359 | # in the ORM-level ResultSetMetaData on each execute, so that |
| 3360 | # it can be targeted by identity after caching |
| 3361 | self.expr = column |
| 3362 | self.translate_raw_column = raw_column_index is not None |
| 3363 | |
| 3364 | self.raw_column_index = raw_column_index |
| 3365 | |
| 3366 | if is_current_entities: |
| 3367 | if parent_bundle: |
| 3368 | self._label_name = orm_key if orm_key else column._proxy_key |
| 3369 | else: |
| 3370 | self._label_name = compile_state._label_convention( |
| 3371 | column, col_name=orm_key |
| 3372 | ) |
| 3373 | else: |
| 3374 | self._label_name = None |
| 3375 | |
| 3376 | _entity._post_inspect |
| 3377 | self.entity_zero = self.entity_zero_or_selectable = ezero = _entity |
| 3378 | self.mapper = mapper = _entity.mapper |
| 3379 | |
| 3380 | if parent_bundle: |
| 3381 | parent_bundle._entities.append(self) |
| 3382 | else: |
| 3383 | entities_collection.append(self) |
| 3384 | |
| 3385 | compile_state._has_orm_entities = True |
| 3386 | |
| 3387 | self.column = column |
| 3388 |
nothing calls this directly
no test coverage detected