diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-16 11:38:24 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-16 11:38:24 -0700 |
commit | 7816b9852b813545a239be53afdd2dc379229614 (patch) | |
tree | 057f095af14cbb46b5abf75e5cc8d5361eec6143 /activerecord/test/cases | |
parent | c9d75e0814a3fa5797c58e3d98f76fa2990c5b5f (diff) | |
parent | 9b66187622453679497ad2fed4f333e2fca32150 (diff) | |
download | rails-7816b9852b813545a239be53afdd2dc379229614.tar.gz rails-7816b9852b813545a239be53afdd2dc379229614.tar.bz2 rails-7816b9852b813545a239be53afdd2dc379229614.zip |
Merge pull request #10619 from alno/top_level_array_in_postgres_json
Support array as root element in Postgresql JSON columns
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/json_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/json_test.rb b/activerecord/test/cases/adapters/postgresql/json_test.rb index 6fc08ae4f0..f45c7afcc0 100644 --- a/activerecord/test/cases/adapters/postgresql/json_test.rb +++ b/activerecord/test/cases/adapters/postgresql/json_test.rb @@ -83,4 +83,18 @@ class PostgresqlJSONTest < ActiveRecord::TestCase x = JsonDataType.first assert_equal(nil, x.payload) end + + def test_select_array_json_value + @connection.execute %q|insert into json_data_type (payload) VALUES ('["v0",{"k1":"v1"}]')| + x = JsonDataType.first + assert_equal(['v0', {'k1' => 'v1'}], x.payload) + end + + def test_rewrite_array_json_value + @connection.execute %q|insert into json_data_type (payload) VALUES ('["v0",{"k1":"v1"}]')| + x = JsonDataType.first + x.payload = ['v1', {'k2' => 'v2'}, 'v3'] + assert x.save! + end + end |