Fix for #334
This commit is contained in:
@@ -18,6 +18,7 @@ import Data.Tree
|
|||||||
import Network.Wai (Request, pathInfo, queryString)
|
import Network.Wai (Request, pathInfo, queryString)
|
||||||
import PostgREST.Types
|
import PostgREST.Types
|
||||||
import Text.ParserCombinators.Parsec hiding (many, (<|>))
|
import Text.ParserCombinators.Parsec hiding (many, (<|>))
|
||||||
|
|
||||||
parseGetRequest :: Request -> Either ParseError ApiRequest
|
parseGetRequest :: Request -> Either ParseError ApiRequest
|
||||||
parseGetRequest httpRequest =
|
parseGetRequest httpRequest =
|
||||||
foldr addFilter <$> (addOrder <$> apiRequest <*> ord) <*> flts
|
foldr addFilter <$> (addOrder <$> apiRequest <*> ord) <*> flts
|
||||||
@@ -77,7 +78,7 @@ lexeme p = ws *> p <* ws
|
|||||||
pTreePath :: Parser (Path,Field)
|
pTreePath :: Parser (Path,Field)
|
||||||
pTreePath = do
|
pTreePath = do
|
||||||
p <- pFieldName `sepBy1` pDelimiter
|
p <- pFieldName `sepBy1` pDelimiter
|
||||||
jp <- optionMaybe ( string "->" >> pJsonPath)
|
jp <- optionMaybe pJsonPath
|
||||||
let pp = map cs p
|
let pp = map cs p
|
||||||
jpp = map cs <$> jp
|
jpp = map cs <$> jp
|
||||||
return (init pp, (last pp, jpp))
|
return (init pp, (last pp, jpp))
|
||||||
@@ -98,14 +99,14 @@ pFieldName :: Parser Text
|
|||||||
pFieldName = cs <$> (many1 (letter <|> digit <|> oneOf "_")
|
pFieldName = cs <$> (many1 (letter <|> digit <|> oneOf "_")
|
||||||
<?> "field name (* or [a..z0..9_])")
|
<?> "field name (* or [a..z0..9_])")
|
||||||
|
|
||||||
pJsonPathDelimiter :: Parser Text
|
pJsonPathStep :: Parser Text
|
||||||
pJsonPathDelimiter = cs <$> (try (string "->>") <|> string "->")
|
pJsonPathStep = cs <$> try (string "->" *> pFieldName)
|
||||||
|
|
||||||
pJsonPath :: Parser [Text]
|
pJsonPath :: Parser [Text]
|
||||||
pJsonPath = pFieldName `sepBy1` pJsonPathDelimiter
|
pJsonPath = (++) <$> many pJsonPathStep <*> ( (:[]) <$> (string "->>" *> pFieldName) )
|
||||||
|
|
||||||
pField :: Parser Field
|
pField :: Parser Field
|
||||||
pField = lexeme $ (,) <$> pFieldName <*> optionMaybe ( pJsonPathDelimiter *> pJsonPath)
|
pField = lexeme $ (,) <$> pFieldName <*> optionMaybe pJsonPath
|
||||||
|
|
||||||
pSelect :: Parser SelectItem
|
pSelect :: Parser SelectItem
|
||||||
pSelect = lexeme $
|
pSelect = lexeme $
|
||||||
|
|||||||
@@ -303,7 +303,6 @@ spec =
|
|||||||
get "/json?data->foo->>bar=not.eq.baz" `shouldRespondWith`
|
get "/json?data->foo->>bar=not.eq.baz" `shouldRespondWith`
|
||||||
[json| [] |]
|
[json| [] |]
|
||||||
it "can filter by properties inside json column using ->>" $ do
|
it "can filter by properties inside json column using ->>" $ do
|
||||||
pendingWith "see issue #334"
|
|
||||||
get "/json?data->>id=eq.1" `shouldRespondWith`
|
get "/json?data->>id=eq.1" `shouldRespondWith`
|
||||||
[json| [{"data": {"id": 1, "foo": {"bar": "baz"}}}] |]
|
[json| [{"data": {"id": 1, "foo": {"bar": "baz"}}}] |]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user