未验证 提交 d27db83d 编写于 作者: R Ryuta Kamizono 提交者: GitHub

Merge pull request #39216 from akinomaeni/fix-incorrectly-successful-datetime-precision-tests

Fix incorrectly successful datetime precision tests
......@@ -25,28 +25,25 @@ class Mysql2DatetimePrecisionQuotingTest < ActiveRecord::Mysql2TestCase
end
end
test "no microsecond precision for MariaDB lt 5.3.0" do
stub_version "5.2.9-MariaDB" do
assert_no_microsecond_precision
end
end
private
def assert_microsecond_precision
assert_match_quoted_microsecond_datetime(/\.000001\z/)
assert_match_quoted_microsecond_datetime(/\.123456\z/)
end
def assert_no_microsecond_precision
assert_match_quoted_microsecond_datetime(/\d\z/)
assert_match_quoted_microsecond_datetime(/:55\z/)
end
def assert_match_quoted_microsecond_datetime(match)
assert_match match, @connection.quoted_date(Time.now.change(usec: 1))
assert_match match, @connection.quoted_date(Time.now.change(sec: 55, usec: 123456))
end
def stub_version(full_version_string)
@connection.stub(:full_version, full_version_string) do
@connection.stub(:get_full_version, full_version_string) do
@connection.schema_cache.clear!
yield
end
ensure
@connection.schema_cache.clear!
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册