Commit 29eabfa
committed
fix(fixer): exclude Python class sentinels from save update_fields inference
The save_without_update_fields fixer was including Python class attributes
(e.g. no_changes = False) in the inferred update_fields list, causing
FieldDoesNotExist errors at runtime on Django 1.11+ since those attributes
are not database columns.
Add _collect_non_field_class_attrs() which scans every class definition in
the module and returns attribute names that are NOT assigned to models.XYZField(...)
instances. These sentinels are excluded from the update_fields suggestion.
Root cause: celery/django-celery#643 CI failure (Python 3.7/Django 1.11
matrix) — our PR included no_changes in update_fields. Fixed in the
django-celery fork (commit 01d5ea9) and now pact itself won't generate
this invalid repair in future.
Two regression tests: sentinel excluded, all-sentinel case → skipped.
305 tests passing.1 parent 6b36d41 commit 29eabfa
2 files changed
Lines changed: 98 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
519 | 562 | | |
520 | 563 | | |
521 | 564 | | |
| |||
599 | 642 | | |
600 | 643 | | |
601 | 644 | | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
602 | 649 | | |
603 | 650 | | |
604 | 651 | | |
| |||
647 | 694 | | |
648 | 695 | | |
649 | 696 | | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
650 | 703 | | |
651 | 704 | | |
652 | 705 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
707 | 707 | | |
708 | 708 | | |
709 | 709 | | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
710 | 755 | | |
711 | 756 | | |
712 | 757 | | |
| |||
0 commit comments