aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-21 11:47:11 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-21 11:48:32 -0700
commite8460f8bbe73537897f2162d1cccda943d8c0f4a (patch)
treedc6eb6b07f4848d4b93d8dc1798a92e31ac3a24e /activerecord/lib/active_record/connection_adapters
parent14599a575850567b28967decffbbbb270fa92676 (diff)
downloadrails-e8460f8bbe73537897f2162d1cccda943d8c0f4a.tar.gz
rails-e8460f8bbe73537897f2162d1cccda943d8c0f4a.tar.bz2
rails-e8460f8bbe73537897f2162d1cccda943d8c0f4a.zip
Don't error when invalid json is assigned to a JSON column
Keeping with our behavior elsewhere in the system, invalid input is assumed to be `nil`. Fixes #18629.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/oid/json.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid/json.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid/json.rb
index e12ddd9901..7dadc09a44 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/json.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/json.rb
@@ -11,7 +11,7 @@ module ActiveRecord
def type_cast_from_database(value)
if value.is_a?(::String)
- ::ActiveSupport::JSON.decode(value)
+ ::ActiveSupport::JSON.decode(value) rescue nil
else
super
end