Repository navigation
fix(migrations): parse arithmetic CHECK constraints - #2178
Open
Zxf-xufeng wants to merge 2 commits into
Open
Zxf-xufeng wants to merge 2 commits into
Zxf-xufeng wants to merge 2 commits into
Conversation
Zxf-xufeng
requested review from
AlexStocks,
PsiACE,
frostming and
zhanghuidinah
as code owners
October 21, 2026 13:27
hidb4ai
reviewed
Oct 21, 2026
hidb4ai
left a comment
Contributor
There was a problem hiding this comment.
The reported addition case is fixed. One issue remains in the newly added remainder support; details inline.
This branch has not been deployed
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.
Which issue or RFC does this PR close?
Closes #2160.
Rationale for this change
Schema reflection rejected PowerContext's own
pc_recall_effort_dailyCHECK (dropped_items = dropped_below_min_bytes + dropped_no_fitting_truncation) as having unbalanced parentheses. The lexer recognized addition, but the expression parser stopped before it, preventing migration status from reaching layout identification.What changes are included in this PR?
+,-,*,/, and%with arithmetic precedence above comparisons and boolean operations. Preserve left associativity, unary signs, and nested grouping when rendering validation SQL.no_parameters=True, so the MySQL driver preserves remainder operators and percent signs inside literals. Constraint violations still raisedata_integrity_error.SHOW CREATE TABLEfixtures for three tables recreated from the 1.3.0 tag's metadata and limits, recording source blob IDs, compiler/binding versions, and engine version.MySQLSchema.validate_data()andMySQLMigrationRunner.plan()for remainder and percent-literal CHECKs, including valid, NULL, and invalid stored values.Are there any user-facing changes?
Migration schema inspection can parse the reported arithmetic CHECK and continue to the actual baseline/support decision. Unsupported CHECK expressions report useful schema context; remainder validation no longer fails in driver parameter interpolation.
There are no API, persisted-schema, dependency, or migration-baseline changes. No tables or constraints are excluded. Successful reflection does not enable upgrades of unregistered complete Server layouts or bypass revision verification, recovery eligibility, and data-integrity checks.
How was this change tested?
TypeError: not enough arguments for format stringon the original PR head through the real seekDB aiomysql bridge for both a remainder CHECK and a percent-containing string literal.POWERCONTEXT_TEST_MIGRATION_SEEKDB=1 .venv/bin/python -m pytest -q tests/builtin/persistence/test_mysql_migration_checks.py tests/builtin/persistence/test_mysql_migration_schema.py --tb=short— 58 passed..venv/bin/python -m pytest -q tests/builtin/persistence/test_*migration*.py tests/test_database_migration*.py tests/test_processing_migration_cli.py --tb=short— 164 passed, 33 skipped (opt-in backend tests).UV_NO_SYNC=1 UV_PYTHON=3.14 make check— passed, including lock consistency, all pre-commit hooks, type checks, workflow/integration consistency, and 50 integration-manifest tests.-k seekdbselector includes both new driver regressions and the historical CHECK tests.Local validation used macOS, Python 3.14.6, SQLAlchemy 2.0.51, aiomysql 0.3.2, and pylibseekdb 1.4.0.post1. The historical fixture was captured on seekDB v1.4.0.0 using 1.3.0 definitions; it is not a customer database or a reproduction of a complete customer upgrade. No live OceanBase test was run. CI results must be checked separately.
AI usage statement
OpenAI Codex inspected the issue and migration contracts, implemented the parser and driver fixes, added regression coverage and CI selection, and ran local validation and a full diff review.