I have the following:
objs =
MyTable.query.options(defer(Table.potentially_very_long_str_column)).all()
for obj in objs:
obj.potentially_very_long_str_column = ''
At the moment, I'm seeing the assignment in the loop issue the `SELECT
potentially_very_long_str_column`, even though that column will be
overwritten.
I pdb'd this down to orm/state.py::InstanceState.modified_event()
where the previous value is stored in self.committed_state
I'm ignorant as to what self.committed_state is used for, but maybe
rather than evaluating 'previous' value, it could be further deferred
until it is needed? This is assuming that self.committed_state will
only be used up until the session is flushed (at which time the
previous value would be lost)..
At the moment, is there any other way of writing to a column without
first reading it using the orm?
Haven't checked, but I assume sql.expression.update doesn't have
this behaviour..
Cheers!
Eoghan
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.