Repository navigation
Conversation
…efault Add handling for computed and identity server defaults in comparison.
…efault Fix missing newline at end of file in server_defaults.py
…efault Add tests for identity and computed column comparisons without gating by compare_server_default option.
…efault Fixed regression in autogenerate detection for Identity and Computed column defaults.
|
Hi, and thanks for the pull request! This project accepts pull requests only for issues that a maintainer has already marked with the open for pull requests label. That way we can settle on an approach before anyone spends time writing code. This pull request references issue #1877, which hasn't been marked open for pull requests, so the change isn't authorized yet and I'm closing it automatically. Once a maintainer adds the label to #1877, reopen this pull request and it will stay open. If #1877 needs more detail before that can happen, a complete runnable example is usually the missing piece, and adding one to the issue is the fastest way to get there. This is automatic and procedural. It isn't a judgment on your change, and nothing you've written here is lost. Thanks for your interest in the project! |
Fixes: #1877
As of 1.18.0, autogenerate no longer detects
Identitychanges on an existing column and no longer emits the "Computed default cannot be modified" warning unlesscompare_server_defaultis set. In 1.17.2 and earlier these ran regardless of that option, which only gated comparison of plain server defaults.Cause
The 1.18 plugin restructure (e532a7e) made the first-priority comparator
_user_compare_server_defaultstop the whole dispatch chain when the option is unset (False), so the computed and identity comparators registered behind it never ran.Fix
When the option is
False,_user_compare_server_defaultnow stops the chain only for plain defaults. If either side isComputedorIdentityit continues, letting_compare_computed_defaultand_compare_identity_defaultrun as they did through the 1.17 series. Plain server default comparison stays gated, and a user callable'sTrue/False/Nonesemantics are unchanged.Tests
New
PGIdentityComputedNoCompareServerDefaultTestin tests/test_postgresql.py covers the four cases from the issue reproducer withcompare_server_default=False(add, remove, and changeIdentity; changeComputedwarns), plus two controls: theIdentitydiff is still detected with the option enabled, and plain server default changes stay gated when it is disabled. The four regression cases fail on main without this change and pass with it; the controls pass both ways.Ran: tests/test_postgresql.py and the server_default/identity/computed test selection against PostgreSQL 16, tests/test_autogen_diffs.py and the same selection against SQLite, plus black, zimports, flake8 and mypy per tox.ini.
This contribution was prepared with AI assistance (Instinct agent): the fix and tests were written with AI tooling and verified locally as described above.