autogenerate: treat empty string comments as no comment (#1085) - #1867
autogenerate: treat empty string comments as no comment (#1085)#1867IMGillusion wants to merge 1 commit into
Conversation
|
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 #1085, 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 #1085, reopen this pull request and it will stay open. If #1085 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 #1085
Problem
Setting
comment=""(empty string) on a column or table in the metadatacauses
autogenerateto report a spurious change on every run, eventhough nothing changed in the database:
it (an empty comment is just no comment), so reflection returns
Nonealembic/autogenerate/compare/comments.pycomparethe reflected
Noneagainst the metadata""with a plain!=,so
None != ""fires a false positive_compare_column_commentemits a spuriousmodify_comment=""(alter column) and
_compare_table_commentemits a spuriousCreateTableCommentOp/DropTableCommentOpThis makes sequential
autogenerateruns non-idempotent for any modelthat uses an empty string comment.
Fix
Normalize
""toNonefor both sides before comparing in_compare_column_commentand_compare_table_comment. An empty commentand no comment are semantically identical (the database cannot
distinguish them), so no diff is reported. Real comment changes
(add/remove/modify a non-empty comment) are unaffected.
Verification
CommentEmptyStringNoFalsePositiveTest(4 tests) in
tests/test_autogen_diffs.pyexercise the comparatorsdirectly with a comment-supporting dialect stub, so they run on any
backend (including sqlite, whose dialect reports
supports_comments=Falseand would otherwise short-circuit thecomparator in an end-to-end run)
*_empty_string_vs_nonetests fail(comparator returns STOP where CONTINUE is expected)
(8 pre-existing environment failures in
test_post_write.pyfailidentically on pristine main)