Skip to content

Business intelligence made simple

Added tests for JSON

Andrew Kanebc1dbc1f0a01
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 @@ class MysqlTest < ActionDispatch::IntegrationTest
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 @@ class PostgresqlTest < ActionDispatch::IntegrationTest
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