passive argument ignored in get_history() for scalar attributes

Issue #1303 duplicate
Michael Bayer
repo owner created an issue


    def get_history(self, state, passive=PASSIVE_OFF):
        return History.from_attribute(
            self, state, state.dict.get(self.key, NO_VALUE))

should be more like:

    def get_history(self, state, passive=PASSIVE_OFF):
        if self.key in state.dict:
            return History.from_attribute(self, state, state.dict[self.key](self.key))
            current = self.get(state, passive=passive)
            if current is PASSIVE_NORESULT:
                return HISTORY_BLANK
                return History.from_attribute(self, state, current)

this to support extensions which need to get attribute history regardless of an object being expired or having deferred columns. workaround is to force a load using getattr(). but the passive flag shouldn't be silently ignored.

however, SA's ORM doesn't need this itself, and the fact that it's ignored right now might be fulfilling part of the current behavioral contract, i.e. don't load the old value unnecessarily. So ensure that get_history() is always called with PASSIVE_OFF for scalars right now and that honoring the flag doesn't result in unnecessary loads.

Comments (3)

  1. Log in to comment