Skip to content

Restore compatible MySQL bulk upserts - #2331

Open
IlyaKhalafi wants to merge 2 commits into
tortoise:developfrom
IlyaKhalafi:fix/mysql-upsert-compatibility
Open

IlyaKhalafi wants to merge 2 commits into
tortoise:developfrom
IlyaKhalafi:fix/mysql-upsert-compatibility

Conversation

@IlyaKhalafi

Copy link
Copy Markdown
Contributor

Description

This PR fixes bulk upserts failing on MariaDB and older MySQL versions. With this, MySQL-family inserts use VALUES(column) assignments without inserted-row aliases.

MySQL 8.0.20 and later deprecate this syntax but still accept it. With asyncmy, server warnings can also add a round trip to fetch and log them. This compatibility tradeoff is documented.

Motivation and Context

Fixes #1422.

How Has This Been Tested?

make check passed. All 11 focused cases passed against MariaDB 10.11.14 with both aiomysql and asyncmy. The unchanged baseline failed eight of those cases. The full SQLite suite passed with 1,981 tests, 153 skips and two expected failures. MySQL 5.7 and modern MySQL were not tested live.

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codspeed

codspeed Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 21 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 24 untouched benchmarks


Comparing IlyaKhalafi:fix/mysql-upsert-compatibility (4210f04) with develop (abc91d7)

Open in CodSpeed

@IlyaKhalafi
IlyaKhalafi force-pushed the fix/mysql-upsert-compatibility branch from 6f04362 to 4210f04 Compare October 23, 2026 16:36

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v0.19: bulk_create doesn't work correctly with on_conflict

1 participant