produce labeled columns present in a select().
(
self,
select,
column,
populate_result_map,
asfrom,
column_clause_args,
name=None,
proxy_name=None,
fallback_label_name=None,
within_columns_clause=True,
column_is_repeated=False,
need_column_expressions=False,
include_table=True,
)
| 4696 | ) |
| 4697 | |
| 4698 | def _label_select_column( |
| 4699 | self, |
| 4700 | select, |
| 4701 | column, |
| 4702 | populate_result_map, |
| 4703 | asfrom, |
| 4704 | column_clause_args, |
| 4705 | name=None, |
| 4706 | proxy_name=None, |
| 4707 | fallback_label_name=None, |
| 4708 | within_columns_clause=True, |
| 4709 | column_is_repeated=False, |
| 4710 | need_column_expressions=False, |
| 4711 | include_table=True, |
| 4712 | ): |
| 4713 | """produce labeled columns present in a select().""" |
| 4714 | impl = column.type.dialect_impl(self.dialect) |
| 4715 | |
| 4716 | if impl._has_column_expression and ( |
| 4717 | need_column_expressions or populate_result_map |
| 4718 | ): |
| 4719 | col_expr = impl.column_expression(column) |
| 4720 | else: |
| 4721 | col_expr = column |
| 4722 | |
| 4723 | if populate_result_map: |
| 4724 | # pass an "add_to_result_map" callable into the compilation |
| 4725 | # of embedded columns. this collects information about the |
| 4726 | # column as it will be fetched in the result and is coordinated |
| 4727 | # with cursor.description when the query is executed. |
| 4728 | add_to_result_map = self._add_to_result_map |
| 4729 | |
| 4730 | # if the SELECT statement told us this column is a repeat, |
| 4731 | # wrap the callable with one that prevents the addition of the |
| 4732 | # targets |
| 4733 | if column_is_repeated: |
| 4734 | _add_to_result_map = add_to_result_map |
| 4735 | |
| 4736 | def add_to_result_map(keyname, name, objects, type_): |
| 4737 | _add_to_result_map(keyname, name, (keyname,), type_) |
| 4738 | |
| 4739 | # if we redefined col_expr for type expressions, wrap the |
| 4740 | # callable with one that adds the original column to the targets |
| 4741 | elif col_expr is not column: |
| 4742 | _add_to_result_map = add_to_result_map |
| 4743 | |
| 4744 | def add_to_result_map(keyname, name, objects, type_): |
| 4745 | _add_to_result_map( |
| 4746 | keyname, name, (column,) + objects, type_ |
| 4747 | ) |
| 4748 | |
| 4749 | else: |
| 4750 | add_to_result_map = None |
| 4751 | |
| 4752 | # this method is used by some of the dialects for RETURNING, |
| 4753 | # which has different inputs. _label_returning_column was added |
| 4754 | # as the better target for this now however for 1.4 we will keep |
| 4755 | # _label_select_column directly compatible with this use case. |
no test coverage detected