Skip to content

Commit

Permalink
Fix broken spec due to EXPLAIN EXTENDED on MySQL 8
Browse files Browse the repository at this point in the history
The behavior that used to be triggered by EXPLAIN EXTENDED has been the
default for a long time and the previously deprecated EXTENDED keyword
was finally removed in MySQL 8.0.

To avoid breaking the spec on very old MySQL versions we just catch the
SQL syntax error and retry without the EXTENDED keyword.
  • Loading branch information
felixbuenemann committed Apr 25, 2019
1 parent 93d3240 commit 2325197
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion spec/mysql2/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,15 @@ def connect *args
it "should > 0" do
# "the statement produces extra information that can be viewed by issuing a SHOW WARNINGS"
# http://dev.mysql.com/doc/refman/5.0/en/explain-extended.html
@client.query("explain extended select 1")
begin
@client.query("explain extended select 1")
rescue Mysql2::Error
# EXTENDED keyword is deprecated in MySQL 8.0 and triggers a syntax error
# https://dev.mysql.com/doc/refman/5.7/en/explain-extended.html
# "extended output is now enabled by default, so the EXTENDED keyword is superfluous and
# deprecated ... and it will be removed from EXPLAIN syntax in a future MySQL release"
@client.query("explain select 1")
end
@client.warning_count.should > 0
end
end
Expand Down

0 comments on commit 2325197

Please sign in to comment.