it passed?

This commit is contained in:
parsonsmatt 2021-03-29 09:46:20 -06:00
parent 4388cccbce
commit 56e0d7afe7

View File

@ -898,41 +898,48 @@ testConcatenationOperator =
testMinusOperator :: Spec testMinusOperator :: Spec
testMinusOperator = testMinusOperator =
describe "Minus Operator" $ do fdescribe "Minus Operator" $ do
it "creates sane SQL" $ it "creates sane SQL" $ do
createSaneSQL @JSONValue let obj = object ["a" .= False, "b" .= True]
(jsonbVal (object ["a" .= False, "b" .= True]) JSON.-. "a") encoded = BSL.toStrict $ encode obj
"SELECT (? - ?)\nFROM \"Json\"\n" createSaneSQL @JSONValue
[ PersistLiteralEscaped "{\"a\":false,\"b\":true}" (jsonbVal obj JSON.-. "a")
, PersistText "a" ] "SELECT (? - ?)\nFROM \"Json\"\n"
it "creates sane SQL (chained)" $ do [ PersistLiteralEscaped encoded
let obj = object ["a" .= [object ["b" .= True]]] , PersistText "a"
createSaneSQL @JSONValue ]
(jsonbVal obj ->. "a" JSON.-. 0) it "creates sane SQL (chained)" $ do
"SELECT ((? -> ?) - ?)\nFROM \"Json\"\n" let obj = object ["a" .= [object ["b" .= True]]]
[ PersistLiteralEscaped "{\"a\":[{\"b\":true}]}" encoded = BSL.toStrict $ encode obj
, PersistText "a" createSaneSQL @JSONValue
, PersistInt64 0 ] (jsonbVal obj ->. "a" JSON.-. 0)
it "works as expected" $ run $ do "SELECT ((? -> ?) - ?)\nFROM \"Json\"\n"
x <- selectJSON $ \v -> do [ PersistLiteralEscaped encoded
where_ $ v @>. jsonbVal (toJSON ([] :: [Int])) , PersistText "a"
where_ $ v JSON.-. 0 @>. jsonbVal (toJSON [Bool True]) , PersistInt64 0
y <- selectJSON $ \v -> do ]
where_ $ v @>. jsonbVal (toJSON ([] :: [Int])) it "works as expected" $ run $ do
where_ $ v JSON.-. (-1) @>. jsonbVal (toJSON [Null]) x <- selectJSON $ \v -> do
z <- selectJSON_ $ \v -> v JSON.-. "b" ?&. ["a", "b"] where_ $ v @>. jsonbVal (toJSON ([] :: [Int]))
w <- selectJSON_ $ \v -> do where_ $ v JSON.-. 0 @>. jsonbVal (toJSON [Bool True])
v JSON.-. "test" @>. jsonbVal (toJSON [String "test"]) y <- selectJSON $ \v -> do
liftIO $ length x `shouldBe` 2 where_ $ v @>. jsonbVal (toJSON ([] :: [Int]))
liftIO $ length y `shouldBe` 1 where_ $ v JSON.-. (-1) @>. jsonbVal (toJSON [Null])
liftIO $ length z `shouldBe` 0 z <- selectJSON_ $ \v -> v JSON.-. "b" ?&. ["a", "b"]
liftIO $ length w `shouldBe` 0 w <- selectJSON_ $ \v -> do
sqlFailWith "22023" $ selectJSONwhere $ \v -> v JSON.-. "test" @>. jsonbVal (toJSON [String "test"])
v JSON.-. 0 @>. jsonbVal (toJSON ([] :: [Int])) liftIO $ length x `shouldBe` 2
where selectJSON_ f = selectJSON $ \v -> do liftIO $ length y `shouldBe` 1
where_ $ v @>. jsonbVal (object []) liftIO $ length z `shouldBe` 0
||. v @>. jsonbVal (toJSON ([] :: [Int])) liftIO $ length w `shouldBe` 0
where_ $ f v sqlFailWith "22023" $ selectJSONwhere $ \v ->
v JSON.-. 0 @>. jsonbVal (toJSON ([] :: [Int]))
where
selectJSON_ f = selectJSON $ \v -> do
where_
$ v @>. jsonbVal (object [])
||. v @>. jsonbVal (toJSON ([] :: [Int]))
where_ $ f v
testMinusOperatorV10 :: Spec testMinusOperatorV10 :: Spec
testMinusOperatorV10 = testMinusOperatorV10 =