fix: Ignore leading and trailing spaces in column names, fts languages and casts
Fixes #2285 Signed-off-by: Wolfgang Walther <walther@technowledgy.de>
This commit is contained in:
committed by
Wolfgang Walther
parent
da632ac7d3
commit
e274706088
@@ -24,6 +24,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- #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
|
- #2362, Fix error message when [] is used inside select - @wolfgangwalther
|
||||||
- #2475, Disallow !inner on computed columns - @wolfgangwalther
|
- #2475, Disallow !inner on computed columns - @wolfgangwalther
|
||||||
|
- #2285, Ignore leading and trailing spaces in column names when parsing the query string - @wolfgangwalther
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|||||||
@@ -352,15 +352,21 @@ pStar = string "*" $> "*"
|
|||||||
-- >>> P.parse pFieldName "" ":"
|
-- >>> P.parse pFieldName "" ":"
|
||||||
-- Left (line 1, column 1):
|
-- Left (line 1, column 1):
|
||||||
-- unexpected ":"
|
-- unexpected ":"
|
||||||
-- expecting field name (* or [a..z0..9_ $])
|
-- expecting field name (* or [a..z0..9_$])
|
||||||
--
|
--
|
||||||
-- >>> P.parse pFieldName "" "\":\""
|
-- >>> P.parse pFieldName "" "\":\""
|
||||||
-- Right ":"
|
-- Right ":"
|
||||||
|
--
|
||||||
|
-- >>> P.parse pFieldName "" " no leading or trailing spaces "
|
||||||
|
-- Right "no leading or trailing spaces"
|
||||||
|
--
|
||||||
|
-- >>> P.parse pFieldName "" "\" leading and trailing spaces \""
|
||||||
|
-- Right " leading and trailing spaces "
|
||||||
pFieldName :: Parser Text
|
pFieldName :: Parser Text
|
||||||
pFieldName =
|
pFieldName =
|
||||||
pQuotedValue <|>
|
pQuotedValue <|>
|
||||||
T.intercalate "-" . map toS <$> (pIdentifier `sepBy1` dash) <?>
|
T.intercalate "-" . map toS <$> (pIdentifier `sepBy1` dash) <?>
|
||||||
"field name (* or [a..z0..9_ $])"
|
"field name (* or [a..z0..9_$])"
|
||||||
where
|
where
|
||||||
isDash :: GenParser Char st ()
|
isDash :: GenParser Char st ()
|
||||||
isDash = try ( char '-' >> notFollowedBy (char '>') )
|
isDash = try ( char '-' >> notFollowedBy (char '>') )
|
||||||
@@ -630,8 +636,11 @@ pLogicPath = do
|
|||||||
pColumns :: Parser [FieldName]
|
pColumns :: Parser [FieldName]
|
||||||
pColumns = pFieldName `sepBy1` lexeme (char ',')
|
pColumns = pFieldName `sepBy1` lexeme (char ',')
|
||||||
|
|
||||||
pIdentifier :: Parser [Char]
|
pIdentifier :: Parser Text
|
||||||
pIdentifier = many1 $ letter <|> digit <|> oneOf "_ $"
|
pIdentifier = T.strip . toS <$> many1 pIdentifierChar
|
||||||
|
|
||||||
|
pIdentifierChar :: Parser Char
|
||||||
|
pIdentifierChar = letter <|> digit <|> oneOf "_ $"
|
||||||
|
|
||||||
mapError :: Either ParseError a -> Either QPError a
|
mapError :: Either ParseError a -> Either QPError a
|
||||||
mapError = mapLeft translateError
|
mapError = mapLeft translateError
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ spec actualPgVersion =
|
|||||||
it "cannot have zero conditions" $
|
it "cannot have zero conditions" $
|
||||||
get "/entities?or=()" `shouldRespondWith`
|
get "/entities?or=()" `shouldRespondWith`
|
||||||
[json|{
|
[json|{
|
||||||
"details": "unexpected \")\" expecting field name (* or [a..z0..9_ $]), negation operator (not) or logic operator (and, or)",
|
"details": "unexpected \")\" expecting field name (* or [a..z0..9_$]), negation operator (not) or logic operator (and, or)",
|
||||||
"message": "\"failed to parse logic tree (())\" (line 1, column 4)",
|
"message": "\"failed to parse logic tree (())\" (line 1, column 4)",
|
||||||
"code": "PGRST100",
|
"code": "PGRST100",
|
||||||
"hint": null
|
"hint": null
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ spec actualPgVersion = do
|
|||||||
{"id": 204, "body": "yyy"},
|
{"id": 204, "body": "yyy"},
|
||||||
{"id": 205, "body": "zzz"}]|]
|
{"id": 205, "body": "zzz"}]|]
|
||||||
`shouldRespondWith`
|
`shouldRespondWith`
|
||||||
[json| {"details":"unexpected end of input expecting field name (* or [a..z0..9_ $])","message":"\"failed to parse columns parameter ()\" (line 1, column 1)","code":"PGRST100","hint":null} |]
|
[json| {"details":"unexpected end of input expecting field name (* or [a..z0..9_$])","message":"\"failed to parse columns parameter ()\" (line 1, column 1)","code":"PGRST100","hint":null} |]
|
||||||
{ matchStatus = 400
|
{ matchStatus = 400
|
||||||
, matchHeaders = []
|
, matchHeaders = []
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user