Transition IN operator and select query param to new block delimiters
This commit is contained in:
@@ -78,8 +78,9 @@ pFieldForest :: Parser [Tree SelectItem]
|
|||||||
pFieldForest = pFieldTree `sepBy1` lexeme (char ',')
|
pFieldForest = pFieldTree `sepBy1` lexeme (char ',')
|
||||||
|
|
||||||
pFieldTree :: Parser (Tree SelectItem)
|
pFieldTree :: Parser (Tree SelectItem)
|
||||||
pFieldTree = try (Node <$> pSimpleSelect <*> between (char '{') (char '}') pFieldForest)
|
pFieldTree = try (Node <$> pSimpleSelect <*> between (char '{') (char '}') pFieldForest)
|
||||||
<|> Node <$> pSelect <*> pure []
|
<|> try (Node <$> pSimpleSelect <*> between (char '(') (char ')') pFieldForest)
|
||||||
|
<|> Node <$> pSelect <*> pure []
|
||||||
|
|
||||||
pStar :: Parser Text
|
pStar :: Parser Text
|
||||||
pStar = toS <$> (string "*" *> pure ("*"::ByteString))
|
pStar = toS <$> (string "*" *> pure ("*"::ByteString))
|
||||||
@@ -143,10 +144,11 @@ pVText :: Parser Operand
|
|||||||
pVText = VText . toS <$> many anyChar
|
pVText = VText . toS <$> many anyChar
|
||||||
|
|
||||||
pVTextL :: Parser Operand
|
pVTextL :: Parser Operand
|
||||||
pVTextL = VTextL <$> lexeme pLValue `sepBy1` char ','
|
pVTextL = VTextL <$> try (lexeme (char '(') *> pVTextLElement `sepBy1` char ',' <* lexeme (char ')'))
|
||||||
where
|
<|> VTextL <$> lexeme pVTextLElement `sepBy1` char ','
|
||||||
pLValue :: Parser Text
|
|
||||||
pLValue = try pQuotedValue <|> (toS <$> many (noneOf ","))
|
pVTextLElement :: Parser Text
|
||||||
|
pVTextLElement = try pQuotedValue <|> (toS <$> many (noneOf ",)"))
|
||||||
|
|
||||||
pQuotedValue :: Parser Text
|
pQuotedValue :: Parser Text
|
||||||
pQuotedValue = toS <$> (char '"' *> many (noneOf "\"") <* char '"' <* notFollowedBy (noneOf ",)"))
|
pQuotedValue = toS <$> (char '"' *> many (noneOf "\"") <* char '"' <* notFollowedBy (noneOf ",)"))
|
||||||
@@ -199,10 +201,7 @@ pLogicVText = VText <$> (try pQuotedValue <|> try pPgArray <|> (toS <$> many (no
|
|||||||
toS <$> pure (a ++ b ++ c)
|
toS <$> pure (a ++ b ++ c)
|
||||||
|
|
||||||
pLogicVTextL :: Parser Operand
|
pLogicVTextL :: Parser Operand
|
||||||
pLogicVTextL = VTextL <$> (lexeme (char '(') *> pLValue `sepBy1` char ',' <* lexeme (char ')'))
|
pLogicVTextL = VTextL <$> (lexeme (char '(') *> pVTextLElement `sepBy1` char ',' <* lexeme (char ')'))
|
||||||
where
|
|
||||||
pLValue :: Parser Text
|
|
||||||
pLValue = try pQuotedValue <|> (toS <$> many (noneOf ",)"))
|
|
||||||
|
|
||||||
pLogicPath :: Parser (EmbedPath, Text)
|
pLogicPath :: Parser (EmbedPath, Text)
|
||||||
pLogicPath = do
|
pLogicPath = do
|
||||||
|
|||||||
@@ -813,3 +813,30 @@ spec = do
|
|||||||
|
|
||||||
it "only returns an empty result set if the in value is empty" $
|
it "only returns an empty result set if the in value is empty" $
|
||||||
get "/items_with_different_col_types?int_data=in. ,3,4" `shouldRespondWith` 400
|
get "/items_with_different_col_types?int_data=in. ,3,4" `shouldRespondWith` 400
|
||||||
|
|
||||||
|
it "returns empty result when the in value is empty between parentheses" $
|
||||||
|
get "/items_with_different_col_types?int_data=in.()" `shouldRespondWith`
|
||||||
|
[json| [] |] { matchHeaders = [matchContentTypeJson] }
|
||||||
|
|
||||||
|
it "returns all results when the notin value is empty between parentheses" $ do
|
||||||
|
get "/items_with_different_col_types?int_data=notin.()&select=int_data" `shouldRespondWith`
|
||||||
|
[json| [{int_data: 1}] |] { matchHeaders = [matchContentTypeJson] }
|
||||||
|
get "/items_with_different_col_types?int_data=not.in.()&select=int_data" `shouldRespondWith`
|
||||||
|
[json| [{int_data: 1}] |] { matchHeaders = [matchContentTypeJson] }
|
||||||
|
|
||||||
|
describe "Transition to url safe characters" $ do
|
||||||
|
context "top level in operator" $ do
|
||||||
|
it "works with parentheses" $
|
||||||
|
get "/entities?id=in.(1,2,3)&select=id" `shouldRespondWith`
|
||||||
|
[json| [{"id": 1}, {"id": 2}, {"id": 3}] |] { matchHeaders = [matchContentTypeJson] }
|
||||||
|
it "works without parentheses" $
|
||||||
|
get "/entities?id=in.1,2,3&select=id" `shouldRespondWith`
|
||||||
|
[json| [{"id": 1}, {"id": 2}, {"id": 3}] |] { matchHeaders = [matchContentTypeJson] }
|
||||||
|
|
||||||
|
context "select query param" $ do
|
||||||
|
it "works with parentheses" $
|
||||||
|
get "/entities?id=eq.2&select=id,child_entities(id)" `shouldRespondWith`
|
||||||
|
[json| [{"id": 2, "child_entities": [{"id": 3}]}] |] { matchHeaders = [matchContentTypeJson] }
|
||||||
|
it "works with brackets" $
|
||||||
|
get "/entities?id=eq.2&select=id,child_entities{id}" `shouldRespondWith`
|
||||||
|
[json| [{"id": 2, "child_entities": [{"id": 3}]}] |] { matchHeaders = [matchContentTypeJson] }
|
||||||
|
|||||||
Reference in New Issue
Block a user