Skip to content

Commit

Permalink
fix: application/vnd.pgrst.array not accepted as a valid mediatype
Browse files Browse the repository at this point in the history
  • Loading branch information
taimoorzaeem authored and steve-chavez committed Aug 11, 2023
1 parent c820efb commit 87d6a0d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### Fixed

- #2899, Fix `application/vnd.pgrst.array` not accepted as a valid mediatype - @taimoorzaeem

## [11.2.0] - 2023-08-10

### Added
Expand Down
1 change: 1 addition & 0 deletions src/PostgREST/MediaType.hs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ decodeMediaType mt =
"application/vnd.pgrst.object+json":rest -> checkSingularNullStrip rest
"application/vnd.pgrst.object":rest -> checkSingularNullStrip rest
"application/vnd.pgrst.array+json":rest -> checkArrayNullStrip rest
"application/vnd.pgrst.array":rest -> checkArrayNullStrip rest
"*/*":_ -> MTAny
other:_ -> MTOther other
_ -> MTAny
Expand Down
10 changes: 10 additions & 0 deletions test/spec/Feature/Query/NullsStrip.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ spec =
, matchHeaders = [matchCTArrayStrip]
}

it "strips nulls when Accept: application/vnd.pgrst.array;nulls=stripped" $
request methodGet "/organizations?select=*"
[("Accept","application/vnd.pgrst.array;nulls=stripped")]
""
`shouldRespondWith`
[json|[{"id":1,"name":"Referee Org","manager_id":1},{"id":2,"name":"Auditor Org","manager_id":2},{"id":3,"name":"Acme","referee":1,"auditor":2,"manager_id":3},{"id":4,"name":"Umbrella","referee":1,"auditor":2,"manager_id":4},{"id":5,"name":"Cyberdyne","referee":3,"auditor":4,"manager_id":5},{"id":6,"name":"Oscorp","referee":3,"auditor":4,"manager_id":6}]|]
{ matchStatus = 200
, matchHeaders = [matchCTArrayStrip]
}

it "strips nulls when Accept: application/vnd.pgrst.object+json;nulls=stripped" $
request methodGet "/organizations?limit=1"
[singularStrip]
Expand Down

0 comments on commit 87d6a0d

Please sign in to comment.