aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-06-06 15:51:57 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-12-11 22:57:29 +0900
commitb01740f9088be49b49f7ed0ca7b73ebbde87bd97 (patch)
tree5878067ca9da1de7dcab6747647a4faeb25c0a6f /activerecord/lib
parent701fc768ae34a8824f0c2611214711f1023b057c (diff)
downloadrails-b01740f9088be49b49f7ed0ca7b73ebbde87bd97.tar.gz
rails-b01740f9088be49b49f7ed0ca7b73ebbde87bd97.tar.bz2
rails-b01740f9088be49b49f7ed0ca7b73ebbde87bd97.zip
Use `inspect` in `type_cast_for_schema` for date/time and decimal values
Currently dumping defaults on schema is inconsistent. Before: ```ruby create_table "defaults", force: :cascade do |t| t.string "string_with_default", default: "Hello!" t.date "date_with_default", default: '2014-06-05' t.datetime "datetime_with_default", default: '2014-06-05 07:17:04' t.time "time_with_default", default: '2000-01-01 07:17:04' t.decimal "decimal_with_default", default: 1234567890 end ``` After: ```ruby create_table "defaults", force: :cascade do |t| t.string "string_with_default", default: "Hello!" t.date "date_with_default", default: "2014-06-05" t.datetime "datetime_with_default", default: "2014-06-05 07:17:04" t.time "time_with_default", default: "2000-01-01 07:17:04" t.decimal "decimal_with_default", default: "1234567890" end ```
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/type/decimal_without_scale.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/type/decimal_without_scale.rb b/activerecord/lib/active_record/type/decimal_without_scale.rb
index 7ce33e9cd3..53a5e205da 100644
--- a/activerecord/lib/active_record/type/decimal_without_scale.rb
+++ b/activerecord/lib/active_record/type/decimal_without_scale.rb
@@ -4,6 +4,10 @@ module ActiveRecord
def type
:decimal
end
+
+ def type_cast_for_schema(value)
+ value.to_s.inspect
+ end
end
end
end