diff --git a/test/Feature/InsertSpec.hs b/test/Feature/InsertSpec.hs index 884628edc..f42f1a0da 100644 --- a/test/Feature/InsertSpec.hs +++ b/test/Feature/InsertSpec.hs @@ -260,7 +260,7 @@ spec actualPgVersion = do context "jsonb" $ do it "serializes nested object" $ do let inserted = [json| { "data": { "foo":"bar" } } |] - request methodPost "/json" + request methodPost "/json_table" [("Prefer", "return=representation")] inserted `shouldRespondWith` [str|[{"data":{"foo":"bar"}}]|] @@ -269,7 +269,7 @@ spec actualPgVersion = do it "serializes nested array" $ do let inserted = [json| { "data": [1,2,3] } |] - request methodPost "/json" + request methodPost "/json_table" [("Prefer", "return=representation")] inserted `shouldRespondWith` [str|[{"data":[1,2,3]}]|] diff --git a/test/Feature/JsonOperatorSpec.hs b/test/Feature/JsonOperatorSpec.hs index 094f5b8f8..6758a1add 100644 --- a/test/Feature/JsonOperatorSpec.hs +++ b/test/Feature/JsonOperatorSpec.hs @@ -140,20 +140,20 @@ spec actualPgVersion = describe "json and jsonb operators" $ do context "filtering response" $ do it "can filter by properties inside json column" $ do - get "/json?data->foo->>bar=eq.baz" `shouldRespondWith` + get "/json_table?data->foo->>bar=eq.baz" `shouldRespondWith` [json| [{"data": {"id": 1, "foo": {"bar": "baz"}}}] |] { matchHeaders = [matchContentTypeJson] } - get "/json?data->foo->>bar=eq.fake" `shouldRespondWith` + get "/json_table?data->foo->>bar=eq.fake" `shouldRespondWith` [json| [] |] { matchHeaders = [matchContentTypeJson] } it "can filter by properties inside json column using not" $ - get "/json?data->foo->>bar=not.eq.baz" `shouldRespondWith` + get "/json_table?data->foo->>bar=not.eq.baz" `shouldRespondWith` [json| [] |] { matchHeaders = [matchContentTypeJson] } it "can filter by properties inside json column using ->>" $ - get "/json?data->>id=eq.1" `shouldRespondWith` + get "/json_table?data->>id=eq.1" `shouldRespondWith` [json| [{"data": {"id": 1, "foo": {"bar": "baz"}}}] |] { matchHeaders = [matchContentTypeJson] } @@ -191,19 +191,19 @@ spec actualPgVersion = describe "json and jsonb operators" $ do context "ordering response" $ do it "orders by a json column property asc" $ - get "/json?order=data->>id.asc" `shouldRespondWith` + get "/json_table?order=data->>id.asc" `shouldRespondWith` [json| [{"data": {"id": 0}}, {"data": {"id": 1, "foo": {"bar": "baz"}}}, {"data": {"id": 3}}] |] { matchHeaders = [matchContentTypeJson] } it "orders by a json column with two level property nulls first" $ - get "/json?order=data->foo->>bar.nullsfirst" `shouldRespondWith` + get "/json_table?order=data->foo->>bar.nullsfirst" `shouldRespondWith` [json| [{"data": {"id": 3}}, {"data": {"id": 0}}, {"data": {"id": 1, "foo": {"bar": "baz"}}}] |] { matchHeaders = [matchContentTypeJson] } context "Patching record, in a nonempty table" $ it "can set a json column to escaped value" $ do - _ <- post "/json" [json| { data: {"escaped":"bar"} } |] - request methodPatch "/json?data->>escaped=eq.bar" + _ <- post "/json_table" [json| { data: {"escaped":"bar"} } |] + request methodPatch "/json_table?data->>escaped=eq.bar" [("Prefer", "return=representation")] [json| { "data": { "escaped":" \"bar" } } |] `shouldRespondWith` [json| [{ "data": { "escaped":" \"bar" } }] |] diff --git a/test/fixtures/data.sql b/test/fixtures/data.sql index f99a11a85..3e080a130 100644 --- a/test/fixtures/data.sql +++ b/test/fixtures/data.sql @@ -257,13 +257,13 @@ SELECT pg_catalog.setval('items2_id_seq', 15, true); -- --- Data for Name: json; Type: TABLE DATA; Schema: test; Owner: - +-- Data for Name: json_table; Type: TABLE DATA; Schema: test; Owner: - -- -TRUNCATE TABLE json CASCADE; -INSERT INTO json VALUES ('{"foo":{"bar":"baz"},"id":1}'); -INSERT INTO json VALUES ('{"id":3}'); -INSERT INTO json VALUES ('{"id":0}'); +TRUNCATE TABLE json_table CASCADE; +INSERT INTO json_table VALUES ('{"foo":{"bar":"baz"},"id":1}'); +INSERT INTO json_table VALUES ('{"id":3}'); +INSERT INTO json_table VALUES ('{"id":0}'); -- diff --git a/test/fixtures/privileges.sql b/test/fixtures/privileges.sql index a1fc30b77..59dadb083 100644 --- a/test/fixtures/privileges.sql +++ b/test/fixtures/privileges.sql @@ -28,7 +28,7 @@ GRANT ALL ON TABLE , has_count_column , has_fk , insertable_view_with_join - , json + , json_table , materialized_view , menagerie , no_pk diff --git a/test/fixtures/schema.sql b/test/fixtures/schema.sql index 12371d403..4e2882ef4 100755 --- a/test/fixtures/schema.sql +++ b/test/fixtures/schema.sql @@ -457,7 +457,7 @@ CREATE TABLE clients ( CREATE TABLE complex_items ( id bigint NOT NULL, name text, - settings pg_catalog.json, + settings json, arr_data integer[], "field-with_sep" integer default 1 not null ); @@ -551,11 +551,11 @@ CREATE VIEW insertable_view_with_join AS JOIN auto_incrementing_pk USING (id)); -- --- Name: json; Type: TABLE; Schema: test; Owner: - +-- Name: json_table; Type: TABLE; Schema: test; Owner: - -- -CREATE TABLE json ( - data pg_catalog.json +CREATE TABLE json_table ( + data json ); @@ -1112,11 +1112,11 @@ create function test.single_out_param(num int, OUT num_plus_one int) AS $$ select num + 1; $$ language sql; -create function test.single_json_out_param(a int, b text, OUT my_json pg_catalog.json) AS $$ +create function test.single_json_out_param(a int, b text, OUT my_json json) AS $$ select json_build_object('a', a, 'b', b); $$ language sql; -create function test.many_out_params(OUT my_json pg_catalog.json, OUT num int, OUT str text) AS $$ +create function test.many_out_params(OUT my_json json, OUT num int, OUT str text) AS $$ select '{"a": 1, "b": "two"}'::json, 3, 'four'::text; $$ language sql; @@ -1152,14 +1152,14 @@ begin end; $$ language plpgsql; -create or replace function test.send_body_status_403() returns pg_catalog.json as $$ +create or replace function test.send_body_status_403() returns json as $$ begin perform set_config('response.status', '403', true); return json_build_object('message', 'invalid user or password'); end; $$ language plpgsql; -create or replace function test.send_bad_status() returns pg_catalog.json as $$ +create or replace function test.send_bad_status() returns json as $$ begin perform set_config('response.status', 'bad', true); return null; @@ -1200,7 +1200,7 @@ create or replace function test.overloaded() returns setof int as $$ values (1), (2), (3); $$ language sql; -create or replace function test.overloaded(pg_catalog.json) returns table(x int, y text) as $$ +create or replace function test.overloaded(json) returns table(x int, y text) as $$ select * from json_to_recordset($1) as r(x int, y text); $$ language sql; @@ -1345,7 +1345,7 @@ create table "UnitTest"( create table json_arr( id integer primary key, - data pg_catalog.json + data json ); create table jsonb_test(