Replies: 1 comment 1 reply
-
As of now, it's pretty naive as I didn't want to issue db queries. A more detailed explanation is here: https://collerek.github.io/ormar/models/#model-save-status So it will fire an update after you reassign the field. The database backends usually have change comparison implemented so the database does not actually update the column if the value is the same (depending on the backend), but the That is a potential enhancement since field access is already happening through descriptors, that can check the previous value, some additional work would be required for |
Beta Was this translation helpful? Give feedback.
-
I see in the docs that there is a
saved
property: https://collerek.github.io/ormar/api/models/new-basemodel/#savedBut I'm not sure to understand if
saved
will return False if I do something likeobj.field = obj.field
(actually not changing anything, but still setting an attribute). Or if Python is clever enough to make it a no-op, something likea = obj.field; obj.field = a
.The goal is to
update
only if the object has changed, to avoid extra queries against the database. But maybe update already checks that the object has changed?Beta Was this translation helpful? Give feedback.
All reactions