Skip to content

Commit 2b0a831

Browse files
authored
Merge pull request #1221 from Shopify/mysql8-update-datetime-casting-error-tests
Update DATETIME casting tests for mysql 8.0
2 parents 6200322 + d79638e commit 2b0a831

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

spec/mysql2/result_spec.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,13 @@
415415
end
416416

417417
it "should raise an error given an invalid DATETIME" do
418-
expect { @client.query("SELECT CAST('1972-00-27 00:00:00' AS DATETIME) as bad_datetime").each }.to \
419-
raise_error(Mysql2::Error, "Invalid date in field 'bad_datetime': 1972-00-27 00:00:00")
418+
if @client.info[:version] < "8.0"
419+
expect { @client.query("SELECT CAST('1972-00-27 00:00:00' AS DATETIME) as bad_datetime").each }.to \
420+
raise_error(Mysql2::Error, "Invalid date in field 'bad_datetime': 1972-00-27 00:00:00")
421+
else
422+
expect(@client.query("SELECT CAST('1972-00-27 00:00:00' AS DATETIME) as bad_datetime").to_a.first).to \
423+
eql("bad_datetime" => nil)
424+
end
420425
end
421426

422427
context "string encoding for ENUM values" do

spec/mysql2/statement_spec.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,13 @@ def stmt_count
482482
end
483483

484484
it "should raise an error given an invalid DATETIME" do
485-
expect { @client.query("SELECT CAST('1972-00-27 00:00:00' AS DATETIME) as bad_datetime").each }.to \
486-
raise_error(Mysql2::Error, "Invalid date in field 'bad_datetime': 1972-00-27 00:00:00")
485+
if @client.info[:version] < "8.0"
486+
expect { @client.query("SELECT CAST('1972-00-27 00:00:00' AS DATETIME) as bad_datetime").each }.to \
487+
raise_error(Mysql2::Error, "Invalid date in field 'bad_datetime': 1972-00-27 00:00:00")
488+
else
489+
expect(@client.query("SELECT CAST('1972-00-27 00:00:00' AS DATETIME) as bad_datetime").to_a.first).to \
490+
eql("bad_datetime" => nil)
491+
end
487492
end
488493

489494
context "string encoding for ENUM values" do

0 commit comments

Comments
 (0)