aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/mysql2/quoting_test.rb
blob: 2de7e1b5269dc0308253ab0634d3a232559870ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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) 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)
    assert_no_match(/\.000001\z/, @connection.quoted_date(t))
  end
end