Skip to content

Commit

Permalink
Merge pull request #51286 from yahonda/wl_13325_mysql_8019
Browse files Browse the repository at this point in the history
MySQL 8.0.19 introduces aliases in the VALUES and SET clauses of INSERT INTO ... ON DUPLICATE KEY UPDATE statement
  • Loading branch information
yahonda committed Mar 8, 2024
1 parent a031f22 commit ce48028
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,9 @@ def default_index_type?(index) # :nodoc:
def build_insert_sql(insert) # :nodoc:
no_op_column = quote_column_name(insert.keys.first)

# Avoid MySQL 8.0 deprecation warning, see https://dev.mysql.com/worklog/task/?id=13325.
if !mariadb? && database_version >= "8.0.0"
# MySQL 8.0.19 replaces `VALUES(<expression>)` clauses with row and column alias names, see https://dev.mysql.com/worklog/task/?id=6312 .
# then MySQL 8.0.20 deprecates the `VALUES(<expression>)` see https://dev.mysql.com/worklog/task/?id=13325 .
if !mariadb? && database_version >= "8.0.19"
values_alias = quote_table_name("#{insert.model.table_name}_values")
sql = +"INSERT #{insert.into} #{insert.values_list} AS #{values_alias}"

Expand Down

0 comments on commit ce48028

Please sign in to comment.