JetBrains / Exposed

Kotlin SQL Framework
http://jetbrains.github.io/Exposed/
Apache License 2.0
8.05k stars 674 forks source link

fix: EXPOSED-340 Syntax error using upsert with MySQL8 below 8.0.19 #2049

Closed bog-walk closed 2 months ago

bog-walk commented 2 months ago

MySQL upsert() uses an alias for the insert row values when the database version is 8+. But this is actually only possible starting with version 8.0.19.

Existing property MysqlDialect.isMysql8 calls isVersionCovers(), which only fetches the database's major and minor version, so it is not sufficient for this comparison. To get the patch version as well requires fetching metadata using the full databaseProductVersion property.

Tested locally with MySQL docker images 8.0.35, 8.0.19, 8.0.18, and 8.0.13.