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

Method row_processor

lib/sqlalchemy/orm/context.py:3046–3094  ·  view source on GitHub ↗
(self, context, result)

Source from the content-addressed store, hash-verified

3044 return self.column.type._isnull
3045
3046 def row_processor(self, context, result):
3047 compile_state = context.compile_state
3048
3049 # the resulting callable is entirely cacheable so just return
3050 # it if we already made one
3051 if self._row_processor is not None:
3052 getter, label_name, extra_entities = self._row_processor
3053 if self.translate_raw_column:
3054 extra_entities += (
3055 context.query._raw_columns[self.raw_column_index],
3056 )
3057
3058 return getter, label_name, extra_entities
3059
3060 # retrieve the column that would have been set up in
3061 # setup_compile_state, to avoid doing redundant work
3062 if self._fetch_column is not None:
3063 column = self._fetch_column
3064 else:
3065 # fetch_column will be None when we are doing a from_statement
3066 # and setup_compile_state may not have been called.
3067 column = self.column
3068
3069 # previously, the RawColumnEntity didn't look for from_obj_alias
3070 # however I can't think of a case where we would be here and
3071 # we'd want to ignore it if this is the from_statement use case.
3072 # it's not really a use case to have raw columns + from_statement
3073 if compile_state._from_obj_alias:
3074 column = compile_state._from_obj_alias.columns[column]
3075
3076 if column._annotations:
3077 # annotated columns perform more slowly in compiler and
3078 # result due to the __eq__() method, so use deannotated
3079 column = column._deannotate()
3080
3081 if compile_state.compound_eager_adapter:
3082 column = compile_state.compound_eager_adapter.columns[column]
3083
3084 getter = result._getter(column)
3085 ret = getter, self._label_name, self._extra_entities
3086 self._row_processor = ret
3087
3088 if self.translate_raw_column:
3089 extra_entities = self._extra_entities + (
3090 context.query._raw_columns[self.raw_column_index],
3091 )
3092 return getter, self._label_name, extra_entities
3093 else:
3094 return ret
3095
3096
3097class _RawColumnEntity(_ColumnEntity):

Callers

nothing calls this directly

Calls 2

_deannotateMethod · 0.45
_getterMethod · 0.45

Tested by

no test coverage detected