If the attributes of an instance are assigned with the same value, would commit result in writes to the database? I just wonder whether it's good practice to update attributes without checking whether that the existing value is actually different to the new value.
The ORM does value checks when flushing and creates updates only on changed values. Quoting the documentation:
At flush time, the value of each attribute is compared to its previously saved value, and if there’s no net change, no SQL operation will occur (this is a more expensive operation so it’s only done at flush time).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With