[Sqlalchemy-tickets] Issue #3857: Attribute history is (sometimes) not updated unless model is quer
Brought to you by:
zzzeek
From: David P. <iss...@bi...> - 2016-11-21 09:27:17
|
New issue 3857: Attribute history is (sometimes) not updated unless model is queried for https://bitbucket.org/zzzeek/sqlalchemy/issues/3857/attribute-history-is-sometimes-not-updated David Pärsson: Consider this example: ```python model = Model(string='first value') session.add(model) session.commit() model.string = 'second value' session.add(model) session.commit() model = session.query(Model).one() model.string = 'third value' session.add(model) session.commit() ``` The `history.deleted` for this attribute is only updated after the model has been queried for: ``` $ python3 repro.py Instance is new. History for attribute "string" is: History(added=['first value'], unchanged=(), deleted=()) Instance is dirty. History for attribute "string" is: History(added=['second value'], unchanged=(), deleted=()) Instance is dirty. History for attribute "string" is: History(added=['third value'], unchanged=(), deleted=['second value']) ``` I would expect `deleted` to be `['first value']` for the first row starting with `Instance is dirty.`. Please se the attached file for the full, runnable example. |