1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #14359 from arthurnn/mysql2_56_franc_sec

MySQL 5.6  Fractional Seconds
This commit is contained in:
Rafael Mendonça França 2014-03-12 10:24:50 -03:00
commit 79ceae6241
5 changed files with 23 additions and 2 deletions

View file

@ -1,3 +1,7 @@
* Support for Mysql 5.6 Fractional Seconds.
*arthurnn*, *Tatsuhiko Miyagawa*
* Support for Postgres `citext` data type enabling case-insensitive where
values without needing to wrap in UPPER/LOWER sql functions.

View file

@ -83,6 +83,14 @@ module ActiveRecord
@connection.escape(string)
end
def quoted_date(value)
if value.acts_like?(:time) && value.respond_to?(:usec)
"#{super}.#{sprintf("%06d", value.usec)}"
else
super
end
end
# CONNECTION MANAGEMENT ====================================
def active?

View file

@ -212,7 +212,7 @@ class BasicsTest < ActiveRecord::TestCase
)
# For adapters which support microsecond resolution.
if current_adapter?(:PostgreSQLAdapter, :SQLite3Adapter)
if current_adapter?(:PostgreSQLAdapter, :SQLite3Adapter) || mysql_56?
assert_equal 11, Topic.find(1).written_on.sec
assert_equal 223300, Topic.find(1).written_on.usec
assert_equal 9900, Topic.find(2).written_on.usec

View file

@ -41,6 +41,11 @@ def in_memory_db?
ActiveRecord::Base.connection_pool.spec.config[:database] == ":memory:"
end
def mysql_56?
current_adapter?(:Mysql2Adapter) &&
ActiveRecord::Base.connection.send(:version).join(".") >= "5.6.0"
end
def supports_savepoints?
ActiveRecord::Base.connection.supports_savepoints?
end

View file

@ -674,7 +674,11 @@ ActiveRecord::Schema.define do
t.string :title
t.string :author_name
t.string :author_email_address
if mysql_56?
t.datetime :written_on, limit: 6
else
t.datetime :written_on
end
t.time :bonus_time
t.date :last_read
# use VARCHAR2(4000) instead of CLOB datatype as CLOB data type has many limitations in