Prevent duplicate call to stored procs
Reuse a CTE for results of call
This commit is contained in:
@@ -422,6 +422,12 @@ spec = do
|
||||
it "GET with 405 on known procs" $
|
||||
get "/rpc/sayhello" `shouldRespondWith` 405
|
||||
|
||||
it "executes the proc exactly once per request" $ do
|
||||
post "/rpc/callcounter" [json| {} |] `shouldRespondWith`
|
||||
[json| [{"callcounter":1}] |]
|
||||
post "/rpc/callcounter" [json| {} |] `shouldRespondWith`
|
||||
[json| [{"callcounter":2}] |]
|
||||
|
||||
describe "weird requests" $ do
|
||||
it "can query as normal" $ do
|
||||
get "/Escap3e;" `shouldRespondWith`
|
||||
|
||||
Vendored
+1
@@ -43,6 +43,7 @@ GRANT INSERT ON TABLE insertonly TO postgrest_test_anonymous;
|
||||
GRANT USAGE ON SEQUENCE
|
||||
auto_incrementing_pk_id_seq
|
||||
, items_id_seq
|
||||
, callcounter_count
|
||||
TO postgrest_test_anonymous;
|
||||
|
||||
-- Privileges for non anonymous users
|
||||
|
||||
Vendored
+12
@@ -261,6 +261,18 @@ CREATE FUNCTION sayhello(name text) RETURNS text
|
||||
$_$;
|
||||
|
||||
|
||||
--
|
||||
-- Name: callcounter(); Type: FUNCTION; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE callcounter_count START 1;
|
||||
|
||||
CREATE FUNCTION callcounter() RETURNS bigint
|
||||
LANGUAGE sql
|
||||
AS $_$
|
||||
SELECT nextval('test.callcounter_count');
|
||||
$_$;
|
||||
|
||||
--
|
||||
-- Name: test_empty_rowset(); Type: FUNCTION; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user