diff options
author | Jori Hardman <jorihardman@gmail.com> | 2015-06-29 11:37:05 -0500 |
---|---|---|
committer | Jori Hardman <jorihardman@gmail.com> | 2015-07-20 15:30:10 -0500 |
commit | e975d7cd1a6cb177f914024ffec8dd9a6cdc4ba1 (patch) | |
tree | 8784c5f481816c0706545edb057caef62d9e94a1 /activerecord/test/cases/adapters | |
parent | a2bb266a7f546edfba8e82e75f1f01bb359f7bbd (diff) | |
download | rails-e975d7cd1a6cb177f914024ffec8dd9a6cdc4ba1.tar.gz rails-e975d7cd1a6cb177f914024ffec8dd9a6cdc4ba1.tar.bz2 rails-e975d7cd1a6cb177f914024ffec8dd9a6cdc4ba1.zip |
Ensure that microsecond precision is only used for version of mysql that support it. Fixes #19711
Diffstat (limited to 'activerecord/test/cases/adapters')
-rw-r--r-- | activerecord/test/cases/adapters/mysql/quoting_test.rb | 14 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/mysql2/quoting_test.rb | 21 |
2 files changed, 35 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/mysql/quoting_test.rb b/activerecord/test/cases/adapters/mysql/quoting_test.rb index a296cf9d31..ca476947fc 100644 --- a/activerecord/test/cases/adapters/mysql/quoting_test.rb +++ b/activerecord/test/cases/adapters/mysql/quoting_test.rb @@ -12,4 +12,18 @@ class MysqlQuotingTest < ActiveRecord::MysqlTestCase def test_type_cast_false assert_equal 0, @conn.type_cast(false) end + + def test_quoted_date_precision_for_gte_564 + @conn.stubs(:full_version).returns('5.6.4') + @conn.remove_instance_variable(:@version) + t = Time.now.change(usec: 1) + assert_match(/\.000001\z/, @conn.quoted_date(t)) + end + + def test_quoted_date_precision_for_lt_564 + @conn.stubs(:full_version).returns('5.6.3') + @conn.remove_instance_variable(:@version) + t = Time.now.change(usec: 1) + refute_match(/\.000001\z/, @conn.quoted_date(t)) + end end diff --git a/activerecord/test/cases/adapters/mysql2/quoting_test.rb b/activerecord/test/cases/adapters/mysql2/quoting_test.rb new file mode 100644 index 0000000000..a49cbba4b4 --- /dev/null +++ b/activerecord/test/cases/adapters/mysql2/quoting_test.rb @@ -0,0 +1,21 @@ +require "cases/helper" + +class Mysql2QuotingTest < ActiveRecord::Mysql2TestCase + setup do + @connection = ActiveRecord::Base.connection + end + + test 'quoted date precision for gte 5.6.4' do + @connection.stubs(:full_version).returns('5.6.4') + @connection.remove_instance_variable(:@version) + t = Time.now.change(usec: 1) + assert_match(/\.000001\z/, @connection.quoted_date(t)) + end + + test 'quoted date precision for lt 5.6.4' do + @connection.stubs(:full_version).returns('5.6.3') + @connection.remove_instance_variable(:@version) + t = Time.now.change(usec: 1) + refute_match(/\.000001\z/, @connection.quoted_date(t)) + end +end |