fix: Stricter query string parsing - no hints or join types in regular fields
Fixes #2362 Reference #2475 Signed-off-by: Wolfgang Walther <walther@technowledgy.de>
This commit is contained in:
committed by
Wolfgang Walther
parent
ae8625a7b6
commit
8c0d187044
+3
-1
@@ -22,12 +22,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- #2343, Return status code 200 for PATCH requests which don't affect any rows - @wolfgangwalther
|
- #2343, Return status code 200 for PATCH requests which don't affect any rows - @wolfgangwalther
|
||||||
- #2481, Treat computed relationships not marked SETOF as M2O/O2O relationship - @wolfgangwalther
|
- #2481, Treat computed relationships not marked SETOF as M2O/O2O relationship - @wolfgangwalther
|
||||||
- #2534, Fix embedding a computed relationship with a normal relationship - @steve-chavez
|
- #2534, Fix embedding a computed relationship with a normal relationship - @steve-chavez
|
||||||
|
- #2362, Fix error message when [] is used inside select - @wolfgangwalther
|
||||||
|
- #2475, Disallow !inner on computed columns - @wolfgangwalther
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- #2444, Removed `db-pool-timeout` option, because this was removed upstream in hasql-pool. - @robx
|
- #2444, Removed `db-pool-timeout` option, because this was removed upstream in hasql-pool. - @robx
|
||||||
- #2343, PATCH requests that don't affect any rows no longer return 404 - @wolfgangwalther
|
- #2343, PATCH requests that don't affect any rows no longer return 404 - @wolfgangwalther
|
||||||
- #2537, Stricter parsing of query string. Instead of silently ignoring, the parser now throws on invalid syntax like json paths for embeddings etc. - @wolfgangwalther
|
- #2537, Stricter parsing of query string. Instead of silently ignoring, the parser now throws on invalid syntax like json paths for embeddings, hints for regular columns, etc. - @wolfgangwalther
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
||||||
|
|||||||
@@ -313,6 +313,11 @@ pTreePath = do
|
|||||||
--
|
--
|
||||||
-- >>> P.parse pFieldForest "" "*,client(*,nested(*))"
|
-- >>> P.parse pFieldForest "" "*,client(*,nested(*))"
|
||||||
-- Right [Node {rootLabel = SelectField {selField = ("*",[]), selCast = Nothing, selAlias = Nothing}, subForest = []},Node {rootLabel = SelectRelation {selRelation = "client", selAlias = Nothing, selHint = Nothing, selJoinType = Nothing}, subForest = [Node {rootLabel = SelectField {selField = ("*",[]), selCast = Nothing, selAlias = Nothing}, subForest = []},Node {rootLabel = SelectRelation {selRelation = "nested", selAlias = Nothing, selHint = Nothing, selJoinType = Nothing}, subForest = [Node {rootLabel = SelectField {selField = ("*",[]), selCast = Nothing, selAlias = Nothing}, subForest = []}]}]}]
|
-- Right [Node {rootLabel = SelectField {selField = ("*",[]), selCast = Nothing, selAlias = Nothing}, subForest = []},Node {rootLabel = SelectRelation {selRelation = "client", selAlias = Nothing, selHint = Nothing, selJoinType = Nothing}, subForest = [Node {rootLabel = SelectField {selField = ("*",[]), selCast = Nothing, selAlias = Nothing}, subForest = []},Node {rootLabel = SelectRelation {selRelation = "nested", selAlias = Nothing, selHint = Nothing, selJoinType = Nothing}, subForest = [Node {rootLabel = SelectField {selField = ("*",[]), selCast = Nothing, selAlias = Nothing}, subForest = []}]}]}]
|
||||||
|
--
|
||||||
|
-- >>> P.parse pFieldForest "" "id,clients(name[])"
|
||||||
|
-- Left (line 1, column 16):
|
||||||
|
-- unexpected '['
|
||||||
|
-- expecting letter, digit, "-", "!", "(", "->>", "->", "::", ")", "," or end of input
|
||||||
pFieldForest :: Parser [Tree SelectItem]
|
pFieldForest :: Parser [Tree SelectItem]
|
||||||
pFieldForest = pFieldTree `sepBy1` lexeme (char ',')
|
pFieldForest = pFieldTree `sepBy1` lexeme (char ',')
|
||||||
where
|
where
|
||||||
@@ -451,6 +456,16 @@ pRelationSelect = lexeme $ try ( do
|
|||||||
--
|
--
|
||||||
-- >>> P.parse pFieldSelect "" "*"
|
-- >>> P.parse pFieldSelect "" "*"
|
||||||
-- Right (SelectField {selField = ("*",[]), selCast = Nothing, selAlias = Nothing})
|
-- Right (SelectField {selField = ("*",[]), selCast = Nothing, selAlias = Nothing})
|
||||||
|
--
|
||||||
|
-- >>> P.parse pFieldSelect "" "name!hint"
|
||||||
|
-- Left (line 1, column 5):
|
||||||
|
-- unexpected '!'
|
||||||
|
-- expecting letter, digit, "-", "->>", "->", "::", ")", "," or end of input
|
||||||
|
--
|
||||||
|
-- >>> P.parse pFieldSelect "" "*!hint"
|
||||||
|
-- Left (line 1, column 2):
|
||||||
|
-- unexpected '!'
|
||||||
|
-- expecting ")", "," or end of input
|
||||||
pFieldSelect :: Parser SelectItem
|
pFieldSelect :: Parser SelectItem
|
||||||
pFieldSelect = lexeme $
|
pFieldSelect = lexeme $
|
||||||
try (
|
try (
|
||||||
@@ -458,11 +473,17 @@ pFieldSelect = lexeme $
|
|||||||
alias <- optionMaybe ( try(pFieldName <* aliasSeparator) )
|
alias <- optionMaybe ( try(pFieldName <* aliasSeparator) )
|
||||||
fld <- pField
|
fld <- pField
|
||||||
cast' <- optionMaybe (string "::" *> many pIdentifierChar)
|
cast' <- optionMaybe (string "::" *> many pIdentifierChar)
|
||||||
|
pEnd
|
||||||
return $ SelectField fld (toS <$> cast') alias
|
return $ SelectField fld (toS <$> cast') alias
|
||||||
)
|
)
|
||||||
<|> do
|
<|> do
|
||||||
s <- pStar
|
s <- pStar
|
||||||
|
pEnd
|
||||||
return $ SelectField (s, []) Nothing Nothing
|
return $ SelectField (s, []) Nothing Nothing
|
||||||
|
where
|
||||||
|
pEnd = try (void $ lookAhead (string ")")) <|>
|
||||||
|
try (void $ lookAhead (string ",")) <|>
|
||||||
|
try eof
|
||||||
|
|
||||||
pOpExpr :: Parser SingleVal -> Parser OpExpr
|
pOpExpr :: Parser SingleVal -> Parser OpExpr
|
||||||
pOpExpr pSVal = try ( string "not" *> pDelimiter *> (OpExpr True <$> pOperation)) <|> OpExpr False <$> pOperation
|
pOpExpr pSVal = try ( string "not" *> pDelimiter *> (OpExpr True <$> pOperation)) <|> OpExpr False <$> pOperation
|
||||||
|
|||||||
Reference in New Issue
Block a user