From bc1dbc1f0a01b0ff169a5f74a659d9def3e8cce4 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 6 Nov 2024 15:01:50 -0800 Subject: [PATCH] Added tests for JSON --- test/adapters/mysql_test.rb | 4 ++++ test/adapters/postgresql_test.rb | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/test/adapters/mysql_test.rb b/test/adapters/mysql_test.rb index 5c288344..cecc4c39 100644 --- a/test/adapters/mysql_test.rb +++ b/test/adapters/mysql_test.rb @@ -96,6 +96,10 @@ def test_binary_output assert_result [{"hello" => "0xF6"}], "SELECT UNHEX('F6') AS hello" end + def test_json_output + assert_result [{"json" => '{"hello": "world"}'}], %!SELECT JSON_OBJECT('hello', 'world') AS json! + end + private def prepared_statements? diff --git a/test/adapters/postgresql_test.rb b/test/adapters/postgresql_test.rb index de80b2ed..ab68b47a 100644 --- a/test/adapters/postgresql_test.rb +++ b/test/adapters/postgresql_test.rb @@ -71,4 +71,12 @@ def test_quoted def test_binary_output assert_result [{"bytea" => "\\x68656c6c6f"}], "SELECT 'hello'::bytea" end + + def test_json_output + assert_result [{"json" => '{"hello": "world"}'}], %!SELECT '{"hello": "world"}'::json! + end + + def test_jsonb_output + assert_result [{"jsonb" => '{"hello": "world"}'}], %!SELECT '{"hello": "world"}'::jsonb! + end end