Sha256: 68fb91a860500b4553050851ab4361ba11b3806ab9208cc5700e82eb77fde787
Contents?: true
Size: 1.2 KB
Versions: 5
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true require "cases/helper" class Mysql2DatetimePrecisionQuotingTest < ActiveRecord::Mysql2TestCase setup do @connection = ActiveRecord::Base.connection end test "microsecond precision for MySQL gte 5.6.4" do stub_version "5.6.4" do assert_microsecond_precision end end test "no microsecond precision for MySQL lt 5.6.4" do stub_version "5.6.3" do assert_no_microsecond_precision end end test "microsecond precision for MariaDB gte 5.3.0" do stub_version "5.5.5-10.1.8-MariaDB-log" do assert_microsecond_precision end end private def assert_microsecond_precision assert_match_quoted_microsecond_datetime(/\.123456\z/) end def assert_no_microsecond_precision assert_match_quoted_microsecond_datetime(/:55\z/) end def assert_match_quoted_microsecond_datetime(match) assert_match match, @connection.quoted_date(Time.now.change(sec: 55, usec: 123456)) end def stub_version(full_version_string) @connection.stub(:get_full_version, full_version_string) do @connection.schema_cache.clear! yield end ensure @connection.schema_cache.clear! end end
Version data entries
5 entries across 5 versions & 1 rubygems