aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/test/cases/adapters/mysql2/quoting_test.rb
blob: 92221e61bf4e76493ac4a3fc8fc8cabf78c9aaef (plain) (tree)
1
2
3
4
5
6
7
8
9








                                                      
                                                                                                        





                                                          
                                                                                                        



                                                          
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) if @connection.instance_variable_defined?(:@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) if @connection.instance_variable_defined?(:@version)
    t = Time.now.change(usec: 1)
    refute_match(/\.000001\z/, @connection.quoted_date(t))
  end
end