Strip PostgreSQL type cast specifiers when comparing computed defaults#1826
Open
cycsmail wants to merge 1 commit into
Open
Strip PostgreSQL type cast specifiers when comparing computed defaults#1826cycsmail wants to merge 1 commit into
cycsmail wants to merge 1 commit into
Conversation
CaselIT
requested changes
Jul 6, 2026
CaselIT
left a comment
Member
There was a problem hiding this comment.
The proposed change cannot be there since it postgresql specific.
Also in the postgresql impl there is already something similar implemented in _cleanup_index_expr that could be re-used for this
CaselIT
reviewed
Jul 6, 2026
| normalized_sqltext = re.sub(r"[ \(\)'\"`\[\]\t\r\n]", "", sqltext).lower() | ||
| # strip postgresql type cast specifiers, e.g. ``::regconfig``, ``::text``, | ||
| # which can appear inconsistently and cause false-positive warnings. | ||
| return re.sub(r"::\w+", "", normalized_sqltext) |
Member
There was a problem hiding this comment.
this can't be here since this is generic for all databases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #1462. On PostgreSQL, reflected computed-column expressions come back with type cast specifiers (e.g.
::regconfig,::text,::char) that aren't present on the metadata side, causing autogenerate to raise a false-positive "Computed default ... cannot be modified" warning even when the expressions are equivalent.Extends
_normalize_computed_default()to strip those::<type>specifiers after the existing whitespace/quote normalization, so the two sides compare equal. Added a unit test normalizing the cast-laden expression from the issue against the cast-free one (fails without the fix, confirmed viagit stash), plus a changelog entry underdocs/build/unreleased/.tests/test_postgresql.pypasses (70 passed) andruff checkis clean on the touched files.Checklist
This pull request is:
Have a nice day!