Merge pull request #18979 from kamipo/extract_precision_from_datetime_and_time_columns
Extract precision from datetime and time columns
This commit is contained in:
commit
b8101afcb8
@ -328,8 +328,8 @@ def find_type(field)
|
||||
|
||||
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 @@ def initialize_type_map(m) # :nodoc:
|
||||
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 @@ def initialize_type_map(m) # :nodoc:
|
||||
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 New Issue
Block a user