Commit 5c31684
fix(plugin-audit): exclude computed fields from update diffs + treat undefined/null as equal (#3293)
Two audit-writer diff bugs surfaced by the objectui record History tab
(gantt QA report showed "紧前依赖(渲染用): [id] → —" on every drag):
1. The beforeUpdate snapshot is read back through the query path, which
computes formula/summary/rollup/autonumber fields; ctx.result is the raw
write result, which does not. diff() therefore recorded a phantom
"value → null" change for every computed field on every update. Computed
fields are now excluded from the diff via the engine schema (their
changes are implied by their source fields); an update touching only
computed fields no longer writes an audit/activity row at all.
2. safeStringify(undefined) returns undefined (JSON.stringify contract),
not a string, so a key absent on one side compared unequal to an
explicit null on the other and wrote a noise row with old=new=null.
Values are normalized with `?? null` before comparison; a real
value → null transition is still recorded (covered by a guard test).
Verified against a live showcase stack: updating showcase_project.health
now writes old_value {"health":"green"} / new_value {"health":"yellow"}
with no task_count/total_estimate phantoms, and the three new regression
tests fail against the pre-fix writer.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent 64e0bbd commit 5c31684
2 files changed
Lines changed: 120 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
443 | 533 | | |
444 | 534 | | |
445 | 535 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
155 | 166 | | |
156 | 167 | | |
157 | | - | |
158 | | - | |
159 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
160 | 171 | | |
161 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
162 | 177 | | |
163 | 178 | | |
164 | 179 | | |
165 | 180 | | |
166 | 181 | | |
167 | | - | |
168 | | - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
169 | 190 | | |
170 | | - | |
171 | | - | |
| 191 | + | |
| 192 | + | |
172 | 193 | | |
173 | 194 | | |
174 | 195 | | |
| |||
455 | 476 | | |
456 | 477 | | |
457 | 478 | | |
458 | | - | |
| 479 | + | |
459 | 480 | | |
460 | 481 | | |
461 | 482 | | |
| |||
0 commit comments