MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / row_processor

Method row_processor

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

Source from the content-addressed store, hash-verified

3185 return self.column.type._isnull
3186
3187 def row_processor(self, context, result):
3188 compile_state = context.compile_state
3189
3190 # the resulting callable is entirely cacheable so just return
3191 # it if we already made one
3192 if self._row_processor is not None:
3193 getter, label_name, extra_entities = self._row_processor
3194 if self.translate_raw_column:
3195 extra_entities += (
3196 context.query._raw_columns[self.raw_column_index],
3197 )
3198
3199 return getter, label_name, extra_entities
3200
3201 # retrieve the column that would have been set up in
3202 # setup_compile_state, to avoid doing redundant work
3203 if self._fetch_column is not None:
3204 column = self._fetch_column
3205 else:
3206 # fetch_column will be None when we are doing a from_statement
3207 # and setup_compile_state may not have been called.
3208 column = self.column
3209
3210 # previously, the RawColumnEntity didn't look for from_obj_alias
3211 # however I can't think of a case where we would be here and
3212 # we'd want to ignore it if this is the from_statement use case.
3213 # it's not really a use case to have raw columns + from_statement
3214 if compile_state._from_obj_alias:
3215 column = compile_state._from_obj_alias.columns[column]
3216
3217 if column._annotations:
3218 # annotated columns perform more slowly in compiler and
3219 # result due to the __eq__() method, so use deannotated
3220 column = column._deannotate()
3221
3222 if compile_state.compound_eager_adapter:
3223 column = compile_state.compound_eager_adapter.columns[column]
3224
3225 getter = result._getter(column)
3226 ret = getter, self._label_name, self._extra_entities
3227 self._row_processor = ret
3228
3229 if self.translate_raw_column:
3230 extra_entities = self._extra_entities + (
3231 context.query._raw_columns[self.raw_column_index],
3232 )
3233 return getter, self._label_name, extra_entities
3234 else:
3235 return ret
3236
3237
3238class _RawColumnEntity(_ColumnEntity):

Callers

nothing calls this directly

Calls 2

_deannotateMethod · 0.45
_getterMethod · 0.45

Tested by

no test coverage detected