Support MySQL 8 row/column alias syntax in executemany INSERT regex#1235
Merged
Conversation
Agent-Logs-Url: https://github.com/PyMySQL/PyMySQL/sessions/7a2a5514-71a3-4f08-910d-8be84935b81e Co-authored-by: methane <[email protected]>
Agent-Logs-Url: https://github.com/PyMySQL/PyMySQL/sessions/7a2a5514-71a3-4f08-910d-8be84935b81e Co-authored-by: methane <[email protected]>
Agent-Logs-Url: https://github.com/PyMySQL/PyMySQL/sessions/7a2a5514-71a3-4f08-910d-8be84935b81e Co-authored-by: methane <[email protected]>
Copilot
AI
changed the title
[WIP] Fix regular expression for new alias syntax in executemany
Support MySQL 8 row/column alias syntax in May 14, 2026
executemany INSERT regex
methane
pushed a commit
that referenced
this pull request
May 15, 2026
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.
Cursor.executemany()fast-path parsing forINSERT ... VALUES ... ON DUPLICATE KEY UPDATEdid not accept MySQL 8.0.19+ alias syntax (VALUES (...) AS alias), so these statements could miss bulk-insert optimization. This updates the parser to recognize the newer syntax while preserving existing behavior.Regex update in
pymysql/cursors.pyRE_INSERT_VALUESsuffix parsing to accept:AS <row_alias>AS <row_alias>(<col_alias>, ...)ON DUPLICATE ...INSERT|REPLACE ... VALUES (...)grouping semantics used byexecutemany().Compatibility preserved
VALUES(col)inON DUPLICATE KEY UPDATEremains supported.Focused coverage in
pymysql/tests/test_cursor.pyVALUES (...) AS new ON DUPLICATE KEY UPDATE ...VALUES (...) AS new(c1,c2,...) ON DUPLICATE KEY UPDATE ...ON DUPLICATE KEY UPDATE ... VALUES(...)