Fix #1264, allow bulk RPC call

This commit is contained in:
steve-chavez
2019-04-05 19:10:00 -05:00
committed by Steve Chávez
parent 40b004c9f7
commit bdfb11001e
4 changed files with 87 additions and 34 deletions
+36
View File
@@ -349,6 +349,42 @@ spec =
[json|"Hello, John"|]
{ matchHeaders = [matchContentTypeJson] }
context "bulk RPC" $ do
it "works with a scalar function an returns a json array" $
post "/rpc/add_them"
[json|[
{"a": 1, "b": 2},
{"a": 4, "b": 6},
{"a": 100, "b": 200}
]|] `shouldRespondWith`
[json|
[3, 10, 300]
|] { matchHeaders = [matchContentTypeJson] }
it "works with a scalar function an returns a json array when posting CSV" $
request methodPost "/rpc/add_them" [("Content-Type", "text/csv")]
"a,b\n1,2\n4,6\n100,200"
`shouldRespondWith`
[json|
[3, 10, 300]
|]
{ matchStatus = 200
, matchHeaders = [matchContentTypeJson]
}
it "works with a non-scalar result" $
post "/rpc/get_projects_below?select=id,name"
[json|[
{"id": 1},
{"id": 5}
]|] `shouldRespondWith`
[json|
[{"id":1,"name":"Windows 7"},
{"id":2,"name":"Windows 10"},
{"id":3,"name":"IOS"},
{"id":4,"name":"OSX"}]
|] { matchHeaders = [matchContentTypeJson] }
context "only for GET rpc" $ do
it "should fail on mutating procs" $ do
get "/rpc/callcounter" `shouldRespondWith` 500
+6 -1
View File
@@ -1659,4 +1659,9 @@ CREATE TABLE test.openapi_types(
"a_numeric" numeric,
"a_real" real,
"a_double_precision" double precision
);
);
create function add_them(a integer, b integer)
returns integer as $$
select a + b;
$$ language sql;