You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know the exact behaviour of get_history, assuming this is a SQLAlchemy function, but assuming it gets the previous object from the session, what you are showing is expected behaviour.
The object gets modified in-place, meaning that the reference to the "previous" value refers to the same object as the "current", and there is no difference between them.
Making changes like this detectable would require some level of explicit (deep) copying of the original data, which would be very unexpected.
You might be able to subclass the MutableJSON type to enable something like that, but it's not something suitable for the basic behaviour I think.
I don't know the exact behaviour of get_history, assuming this is a SQLAlchemy function, but assuming it gets the previous object from the session, what you are showing is expected behaviour.
The object gets modified in-place, meaning that the reference to the "previous" value refers to the same object as the "current", and there is no difference between them.
Making changes like this detectable would require some level of explicit (deep) copying of the original data, which would be very unexpected.
You might be able to subclass the MutableJSON type to enable something like that, but it's not something suitable for the basic behaviour I think.
sqlalchemy.orm.attributes import get_history will return History object which has three attr:
added : the collection of elements added to the attribute
unchanged : the collection of elements that have not changed on the attribute
deleted : the collection of elements that have been deleted from the attribute.
I guess you are right, i might need to use subclass to implement this
I try to get object change using following code, but MutableJSON has no history getted
The text was updated successfully, but these errors were encountered: