diff options
author | Alexey Noskov <alexey.noskov@gmail.com> | 2013-05-14 17:44:32 +0400 |
---|---|---|
committer | Alexey Noskov <alexey.noskov@gmail.com> | 2013-05-14 17:44:32 +0400 |
commit | 9b66187622453679497ad2fed4f333e2fca32150 (patch) | |
tree | 5eb14fe537d0f7de4c590aa1bddc1ea650275d5d /activerecord/test/cases/adapters | |
parent | e100d1e489a9d88e86510fcc8f1bdfe0fb54f6a7 (diff) | |
download | rails-9b66187622453679497ad2fed4f333e2fca32150.tar.gz rails-9b66187622453679497ad2fed4f333e2fca32150.tar.bz2 rails-9b66187622453679497ad2fed4f333e2fca32150.zip |
Support array as root element in JSON
Diffstat (limited to 'activerecord/test/cases/adapters')
-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 |