aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-02-11 08:24:47 -0700
committerSean Griffin <sean@seantheprogrammer.com>2015-02-11 08:24:47 -0700
commit9a656a7776b2be0a13f8f20eedbca7fb5d184b34 (patch)
tree01e613f29a06b46a5252bf592d4a94be962d00ea /activerecord/lib
parent3ffffcc39dec63e2c0e3c57a76c31649c781989e (diff)
parent18e0ffe90f22dee975d40de40eb24d49765b14e8 (diff)
downloadrails-9a656a7776b2be0a13f8f20eedbca7fb5d184b34.tar.gz
rails-9a656a7776b2be0a13f8f20eedbca7fb5d184b34.tar.bz2
rails-9a656a7776b2be0a13f8f20eedbca7fb5d184b34.zip
Merge pull request #18883 from kamipo/fix_datetime_precision_dumping_zero_for_postgresql
The datetime precision with zero should be dumped
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb2
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb6
2 files changed, 7 insertions, 1 deletions
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