mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Extract precision from datetime and time columns
The cause by which the test suite for the mysql adapter broke in1502cae
(reverted89ba5bb
) is because the precision was not extracted. The rounding problem in mysql adapter has not been fixed, but `mysql_56` helper tested only mysql2 adapter, its behavior was not apparent.
This commit is contained in:
parent
06d5d2c5e9
commit
4b38a99e7a
3 changed files with 5 additions and 8 deletions
|
@ -328,8 +328,8 @@ module ActiveRecord
|
|||
|
||||
def initialize_type_map(m) # :nodoc:
|
||||
super
|
||||
m.register_type %r(datetime)i, Fields::DateTime.new
|
||||
m.register_type %r(time)i, Fields::Time.new
|
||||
register_class_with_precision m, %r(datetime)i, Fields::DateTime
|
||||
register_class_with_precision m, %r(time)i, Fields::Time
|
||||
end
|
||||
|
||||
def exec_without_stmt(sql, name = 'SQL') # :nodoc:
|
||||
|
|
|
@ -477,7 +477,6 @@ module ActiveRecord
|
|||
register_class_with_limit m, 'varbit', OID::BitVarying
|
||||
m.alias_type 'timestamptz', 'timestamp'
|
||||
m.register_type 'date', Type::Date.new
|
||||
m.register_type 'time', Type::Time.new
|
||||
|
||||
m.register_type 'money', OID::Money.new
|
||||
m.register_type 'bytea', OID::Bytea.new
|
||||
|
@ -503,10 +502,8 @@ module ActiveRecord
|
|||
m.alias_type 'lseg', 'varchar'
|
||||
m.alias_type 'box', 'varchar'
|
||||
|
||||
m.register_type 'timestamp' do |_, _, sql_type|
|
||||
precision = extract_precision(sql_type)
|
||||
OID::DateTime.new(precision: precision)
|
||||
end
|
||||
register_class_with_precision m, 'time', Type::Time
|
||||
register_class_with_precision m, 'timestamp', OID::DateTime
|
||||
|
||||
m.register_type 'numeric' do |_, fmod, sql_type|
|
||||
precision = extract_precision(sql_type)
|
||||
|
|
|
@ -46,7 +46,7 @@ def in_memory_db?
|
|||
end
|
||||
|
||||
def mysql_56?
|
||||
current_adapter?(:Mysql2Adapter) &&
|
||||
current_adapter?(:MysqlAdapter, :Mysql2Adapter) &&
|
||||
ActiveRecord::Base.connection.send(:version).join(".") >= "5.6.0"
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue