From 7c7a04a27ebadaba610419cfc7dcbbf41daf022c Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Thu, 27 Oct 2022 13:07:13 +0200 Subject: [PATCH] test: Add doctests for pFieldForest Signed-off-by: Wolfgang Walther --- src/PostgREST/ApiRequest/QueryParams.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/PostgREST/ApiRequest/QueryParams.hs b/src/PostgREST/ApiRequest/QueryParams.hs index ad3c2d5b4..5a428e141 100644 --- a/src/PostgREST/ApiRequest/QueryParams.hs +++ b/src/PostgREST/ApiRequest/QueryParams.hs @@ -302,6 +302,17 @@ pTreePath = do jp <- P.option [] pJsonPath return (init p, (last p, jp)) +-- | +-- Parse select= into a Forest of SelectItems +-- +-- >>> P.parse pFieldForest "" "id" +-- Right [Node {rootLabel = SelectField {selField = ("id",[]), selCast = Nothing, selAlias = Nothing}, subForest = []}] +-- +-- >>> P.parse pFieldForest "" "client(id)" +-- Right [Node {rootLabel = SelectRelation {selField = ("client",[]), selAlias = Nothing, selHint = Nothing, selJoinType = Nothing}, subForest = [Node {rootLabel = SelectField {selField = ("id",[]), selCast = Nothing, selAlias = Nothing}, subForest = []}]}] +-- +-- >>> P.parse pFieldForest "" "*,client(*,nested(*))" +-- Right [Node {rootLabel = SelectField {selField = ("*",[]), selCast = Nothing, selAlias = Nothing}, subForest = []},Node {rootLabel = SelectRelation {selField = ("client",[]), selAlias = Nothing, selHint = Nothing, selJoinType = Nothing}, subForest = [Node {rootLabel = SelectField {selField = ("*",[]), selCast = Nothing, selAlias = Nothing}, subForest = []},Node {rootLabel = SelectRelation {selField = ("nested",[]), selAlias = Nothing, selHint = Nothing, selJoinType = Nothing}, subForest = [Node {rootLabel = SelectField {selField = ("*",[]), selCast = Nothing, selAlias = Nothing}, subForest = []}]}]}] pFieldForest :: Parser [Tree SelectItem] pFieldForest = pFieldTree `sepBy1` lexeme (char ',') where