zephyring commented on code in PR #25043:
URL: https://github.com/apache/superset/pull/25043#discussion_r1300988121
##########
superset/daos/base.py:
##########
@@ -171,10 +171,17 @@ def update(cls, model: T, properties: dict[str, Any],
commit: bool = True) -> T:
Generic update a model
:raises: DAOCreateFailedError
"""
+ d = dict(model.__dict__)
+ d.pop("_sa_instance_state") # get rid of SQLAlchemy special attr
+ copy = model.__class__(**d)
+ copy.id = model.id
+ # create a copy of the model here
+ # so it doesn't trigger before_update/after_update sqla listener each
time
+ # we set a property
Review Comment:
this is an important change to the base update method.
By creating a out of session copy of the original model instance, we can set
attributes on the copy without worrying the before/after update sqla listener
will be triggered for each property.
The listener will only be triggered when session is committed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]