Call procedures that return setof, not just text
The output is too deeply nested however
This commit is contained in:
@@ -168,10 +168,11 @@ app conf reqBody req =
|
|||||||
exists <- doesProcExist schema proc
|
exists <- doesProcExist schema proc
|
||||||
if exists
|
if exists
|
||||||
then do
|
then do
|
||||||
row :: Maybe (Identity Text) <- H.maybeEx $ callProc qi $
|
let call = B.Stmt "select " V.empty True <>
|
||||||
fromMaybe M.empty (decode reqBody)
|
asJson (callProc qi $ fromMaybe M.empty (decode reqBody))
|
||||||
return $ responseLBS status200 [textH]
|
body :: Maybe (Identity Text) <- H.maybeEx call
|
||||||
(cs $ fromMaybe "" $ runIdentity <$> row)
|
return $ responseLBS status200 [jsonH]
|
||||||
|
(cs $ fromMaybe "[]" $ runIdentity <$> body)
|
||||||
else return $ responseLBS status404 [] ""
|
else return $ responseLBS status404 [] ""
|
||||||
|
|
||||||
-- check that proc exists
|
-- check that proc exists
|
||||||
|
|||||||
Vendored
+22
@@ -217,6 +217,17 @@ ALTER SEQUENCE items_id_seq OWNED BY items.id;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE FUNCTION "1".getitemrange(min bigint, max bigint) RETURNS SETOF "1".items AS $$
|
||||||
|
SELECT * FROM "1".items WHERE id > $1 AND id <= $2;
|
||||||
|
$$ LANGUAGE SQL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE FUNCTION "1".sayhello(name text) RETURNS text AS $$
|
||||||
|
SELECT 'Hello, ' || $1;
|
||||||
|
$$ LANGUAGE SQL;
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE menagerie (
|
CREATE TABLE menagerie (
|
||||||
"integer" integer NOT NULL,
|
"integer" integer NOT NULL,
|
||||||
double double precision NOT NULL,
|
double double precision NOT NULL,
|
||||||
@@ -521,6 +532,17 @@ GRANT ALL ON TABLE items TO postgrest_test;
|
|||||||
GRANT ALL ON TABLE items TO postgrest_anonymous;
|
GRANT ALL ON TABLE items TO postgrest_anonymous;
|
||||||
|
|
||||||
|
|
||||||
|
REVOKE ALL ON FUNCTION getitemrange(bigint, bigint) FROM PUBLIC;
|
||||||
|
REVOKE ALL ON FUNCTION getitemrange(bigint, bigint) FROM postgrest_test;
|
||||||
|
GRANT EXECUTE ON FUNCTION getitemrange(bigint, bigint) TO postgrest_test;
|
||||||
|
GRANT EXECUTE ON FUNCTION getitemrange(bigint, bigint) TO postgrest_anonymous;
|
||||||
|
|
||||||
|
|
||||||
|
REVOKE ALL ON FUNCTION sayhello(text) FROM PUBLIC;
|
||||||
|
REVOKE ALL ON FUNCTION sayhello(text) FROM postgrest_test;
|
||||||
|
GRANT EXECUTE ON FUNCTION sayhello(text) TO postgrest_test;
|
||||||
|
GRANT EXECUTE ON FUNCTION sayhello(text) TO postgrest_anonymous;
|
||||||
|
|
||||||
|
|
||||||
REVOKE ALL ON SEQUENCE items_id_seq FROM PUBLIC;
|
REVOKE ALL ON SEQUENCE items_id_seq FROM PUBLIC;
|
||||||
REVOKE ALL ON SEQUENCE items_id_seq FROM postgrest_test;
|
REVOKE ALL ON SEQUENCE items_id_seq FROM postgrest_test;
|
||||||
|
|||||||
Reference in New Issue
Block a user