Commit fd4f6b3
committed
[fix] Correct handling of deferred fields when tracking changed fields
When a Device instance was loaded with deferred fields (e.g. using
QuerySet.only()), `_check_changed_fields()` incorrectly populated the
`_initial_<field>` attributes. Instead of storing the original value
retrieved from the database, it stored the field name itself.
This happened because the code iterated over `_changed_checked_fields`
and assigned the field name rather than the actual value coming from
`present_values`.
The logic has been updated to iterate over `present_values.items()`,
store the current database value in `_initial_<field>`, and then
restore the updated value on the instance.
This ensures change detection works correctly even when fields were
initially deferred.
Changelog (Bugfix):
Fixed incorrect initialization of `_initial_<field>` values when a
Device instance is loaded with deferred fields, which could break
change detection logic.1 parent af0d99b commit fd4f6b3
File tree
2 files changed
+18
-3
lines changed- openwisp_controller/config
- base
- tests
2 files changed
+18
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
341 | | - | |
342 | | - | |
343 | | - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
541 | 541 | | |
542 | 542 | | |
543 | 543 | | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
544 | 559 | | |
545 | 560 | | |
546 | 561 | | |
| |||
0 commit comments