From 18e0ffe90f22dee975d40de40eb24d49765b14e8 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Wed, 11 Feb 2015 09:42:37 +0900 Subject: The datetime precision with zero should be dumped `precision: 0` was not dumped by f1a0fa9e19b7e4ccaea191fc6cf0613880222ee7. However, `precision: 0` is valid value for PostgreSQL timestamps. --- .../lib/active_record/connection_adapters/abstract/schema_dumper.rb | 2 +- .../lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb index 4f6a1ec67b..932aaf7aa7 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb @@ -29,7 +29,7 @@ module ActiveRecord limit = column.limit || native_database_types[column.type][:limit] spec[:limit] = limit.inspect if limit - spec[:precision] = column.precision.inspect if column.precision && column.precision != 0 + spec[:precision] = column.precision.inspect if column.precision spec[:scale] = column.scale.inspect if column.scale default = schema_default(column) if column.has_default? diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index 054c59ef5c..17d38da129 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -73,6 +73,12 @@ module ActiveRecord spec end + def prepare_column_options(column) + spec = super + spec.delete(:precision) if column.type == :datetime && column.precision == 0 + spec + end + class Column < ConnectionAdapters::Column # :nodoc: delegate :strict, :collation, :extra, to: :sql_type_metadata, allow_nil: true -- cgit v1.2.3