fix: is not working with upper/mixed case values (#2081)
This commit is contained in:
@@ -10,6 +10,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- #2020, Execute deferred constraint triggers when using `Prefer: tx=rollback` - @wolfgangwalther
|
- #2020, Execute deferred constraint triggers when using `Prefer: tx=rollback` - @wolfgangwalther
|
||||||
|
- #2058, Return 204 No Content without Content-Type for PUT - @wolfgangwalther
|
||||||
|
- #2077, Fix `is` not working with upper or mixed case values like `NULL, TrUe, FaLsE` - @steve-chavez
|
||||||
|
|
||||||
## [9.0.0] - 2021-11-25
|
## [9.0.0] - 2021-11-25
|
||||||
|
|
||||||
|
|||||||
@@ -199,10 +199,10 @@ pOpExpr pSVal = try ( string "not" *> pDelimiter *> (OpExpr True <$> pOperation)
|
|||||||
<|> pFts
|
<|> pFts
|
||||||
<?> "operator (eq, gt, ...)"
|
<?> "operator (eq, gt, ...)"
|
||||||
|
|
||||||
pTriVal = try (string "null" $> TriNull)
|
pTriVal = try (ciString "null" $> TriNull)
|
||||||
<|> try (string "unknown" $> TriUnknown)
|
<|> try (ciString "unknown" $> TriUnknown)
|
||||||
<|> try (string "true" $> TriTrue)
|
<|> try (ciString "true" $> TriTrue)
|
||||||
<|> try (string "false" $> TriFalse)
|
<|> try (ciString "false" $> TriFalse)
|
||||||
<?> "null or trilean value (unknown, true, false)"
|
<?> "null or trilean value (unknown, true, false)"
|
||||||
|
|
||||||
pFts = do
|
pFts = do
|
||||||
@@ -213,6 +213,12 @@ pOpExpr pSVal = try ( string "not" *> pDelimiter *> (OpExpr True <$> pOperation)
|
|||||||
ops = M.filterWithKey (const . flip notElem ("in":"is":ftsOps)) operators
|
ops = M.filterWithKey (const . flip notElem ("in":"is":ftsOps)) operators
|
||||||
ftsOps = M.keys ftsOperators
|
ftsOps = M.keys ftsOperators
|
||||||
|
|
||||||
|
-- case insensitive char and string
|
||||||
|
ciChar :: Char -> GenParser Char state Char
|
||||||
|
ciChar c = char c <|> char (toUpper c)
|
||||||
|
ciString :: [Char] -> GenParser Char state [Char]
|
||||||
|
ciString = traverse ciChar
|
||||||
|
|
||||||
pSingleVal :: Parser SingleVal
|
pSingleVal :: Parser SingleVal
|
||||||
pSingleVal = toS <$> many anyChar
|
pSingleVal = toS <$> many anyChar
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,23 @@ spec actualPgVersion = do
|
|||||||
[json| [{"id": 3, "name": "wash the dishes", "done": null }] |]
|
[json| [{"id": 3, "name": "wash the dishes", "done": null }] |]
|
||||||
{ matchHeaders = [matchContentTypeJson] }
|
{ matchHeaders = [matchContentTypeJson] }
|
||||||
|
|
||||||
|
it "matches with trilean values in upper or mixed case" $ do
|
||||||
|
get "/chores?done=is.NULL" `shouldRespondWith`
|
||||||
|
[json| [{"id": 3, "name": "wash the dishes", "done": null }] |]
|
||||||
|
{ matchHeaders = [matchContentTypeJson] }
|
||||||
|
|
||||||
|
get "/chores?done=is.TRUE" `shouldRespondWith`
|
||||||
|
[json| [{"id": 1, "name": "take out the garbage", "done": true }] |]
|
||||||
|
{ matchHeaders = [matchContentTypeJson] }
|
||||||
|
|
||||||
|
get "/chores?done=is.FAlSe" `shouldRespondWith`
|
||||||
|
[json| [{"id": 2, "name": "do the laundry", "done": false }] |]
|
||||||
|
{ matchHeaders = [matchContentTypeJson] }
|
||||||
|
|
||||||
|
get "/chores?done=is.UnKnOwN" `shouldRespondWith`
|
||||||
|
[json| [{"id": 3, "name": "wash the dishes", "done": null }] |]
|
||||||
|
{ matchHeaders = [matchContentTypeJson] }
|
||||||
|
|
||||||
it "fails if 'is' used and there's no null or trilean value" $ do
|
it "fails if 'is' used and there's no null or trilean value" $ do
|
||||||
get "/chores?done=is.nil" `shouldRespondWith` 400
|
get "/chores?done=is.nil" `shouldRespondWith` 400
|
||||||
get "/chores?done=is.ok" `shouldRespondWith` 400
|
get "/chores?done=is.ok" `shouldRespondWith` 400
|
||||||
|
|||||||
Reference in New Issue
Block a user