Fix Content-Profile not working for POST RPC

Accept-Profile was applied instead.

Fixes https://github.com/PostgREST/postgrest/issues/1508.
This commit is contained in:
steve-chavez
2020-05-02 11:51:32 -05:00
committed by Steve Chavez
parent f57caf0987
commit 9a52632024
4 changed files with 17 additions and 2 deletions
+1
View File
@@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- #1473, Fix overloaded computed columns on RPC - @wolfgangwalther
- #1471, Fix POST, PATCH, DELETE with ?select= and return=minimal and PATCH with empty body - @wolfgangwalther
- #1500, Fix missing `openapi-server-proxy-uri` config option - @steve-chavez
- #1508, Fix `Content-Profile` not working for POST RPC - @steve-chavez
## [7.0.0] - 2020-04-03
+2
View File
@@ -7,6 +7,8 @@ check: lint style test
clean: prompt-clean
stack clean --full
# For running these you'll need to install hlint and stylish-haskell first. Run:
# stack install hlint stylish-haskell
lint:
git ls-files | grep '\.l\?hs$$' | xargs stack exec -- hlint -X QuasiQuotes -X NoPatternSynonyms "$$@"
+2 -2
View File
@@ -220,9 +220,9 @@ userApiRequest confSchemas rootSpec req reqBody
profile
| length confSchemas <= 1 -- only enable content negotiation by profile when there are multiple schemas specified in the config
= Nothing
| action `elem` [ActionCreate, ActionUpdate, ActionSingleUpsert, ActionDelete] -- POST/PATCH/PUT/DELETE don't use the same header as per the spec
| action `elem` [ActionCreate, ActionUpdate, ActionSingleUpsert, ActionDelete, ActionInvoke InvPost] -- POST/PATCH/PUT/DELETE don't use the same header as per the spec
= Just $ maybe defaultSchema toS $ lookupHeader "Content-Profile"
| action `elem` [ActionRead True, ActionRead False, ActionInvoke InvGet, ActionInvoke InvHead, ActionInvoke InvPost,
| action `elem` [ActionRead True, ActionRead False, ActionInvoke InvGet, ActionInvoke InvHead,
ActionInspect False, ActionInspect True, ActionInfo]
= Just $ maybe defaultSchema toS $ lookupHeader "Accept-Profile"
| otherwise = Nothing
+12
View File
@@ -146,6 +146,18 @@ spec actualPgVersion =
, matchHeaders = [matchContentTypeJson, "Content-Profile" <:> "v2"]
}
it "succeeds in calling the v2 schema proc with POST by using Content-Profile" $
request methodPost "/rpc/get_parents_below?select=id,name" [("Content-Profile", "v2")]
[json|{"id": "6"}|]
`shouldRespondWith`
[json| [
{"id":3,"name":"parent v2-3"},
{"id":4,"name":"parent v2-4"}]|]
{
matchStatus = 200
, matchHeaders = [matchContentTypeJson, "Content-Profile" <:> "v2"]
}
context "Modifying tables on different schemas" $ do
it "succeeds in patching on the v1 schema and returning its parent" $
request methodPatch "/children?select=name,parent(name)&id=eq.1" [("Content-Profile", "v1"), ("Prefer", "return=representation")]