envs::{ stores:[ { id:"5", books:[ { title:"A", price:5.0, categories:[ "sci-fi", "action" ] }, { title:"B", price:2.0, categories:[ "sci-fi", "comedy" ] }, { title:"C", price:7.0, categories:[ "action", "suspense" ] }, { title:"D", price:9.0, categories:[ "suspense" ] } ] }, { id:"6", books:[ { title:"A", price:5.0, categories:[ "sci-fi", "action" ] }, { title:"E", price:9.5, categories:[ "fantasy", "comedy" ] }, { title:"F", price:10.0, categories:[ "history" ] } ] }, { id:"7", books:[ ] } ], prices:[ 5, 2e0 ], } in::[ { name:"inPredicate", statement:"SELECT VALUE b.title FROM stores[*].books[*] AS b WHERE b.price IN (5, `2e0`)", assert:{ evalMode:[EvalModeCoerce, EvalModeError], result:EvaluationSuccess, output:$bag::[ "A", "B", "A" ] } }, { name:"inPredicateSingleItem", statement:"SELECT VALUE b.title FROM stores[*].books[*] AS b WHERE b.price IN (5)", assert:{ evalMode:[EvalModeCoerce, EvalModeError], result:EvaluationSuccess, output:$bag::[ "A", "A" ] } }, { name:"inPredicateSingleExpr", statement:"SELECT VALUE b.title FROM stores[*].books[*] AS b WHERE b.price IN 5", assert:{ evalMode:[EvalModeCoerce, EvalModeError], result:EvaluationSuccess, output:$bag::[ ] } }, { name:"inPredicateSingleItemListVar", statement:"SELECT VALUE b.title FROM stores[*].books[*] AS b WHERE b.price IN (prices)", assert:{ evalMode:[EvalModeCoerce, EvalModeError], result:EvaluationSuccess, output:$bag::[ ] } }, { name:"inPredicateSingleListVar", statement:"SELECT VALUE b.title FROM stores[*].books[*] AS b WHERE b.price IN prices", assert:{ evalMode:[EvalModeCoerce, EvalModeError], result:EvaluationSuccess, output:$bag::[ "A", "B", "A" ] } }, { name:"inPredicateSubQuerySelectValue", statement:"SELECT VALUE b.title FROM stores[*].books[*] AS b WHERE b.price IN (SELECT VALUE p FROM prices AS p)", assert:{ evalMode:[EvalModeCoerce, EvalModeError], result:EvaluationSuccess, output:$bag::[ "A", "B", "A" ] } }, { name:"notInPredicate", statement:"SELECT VALUE b.title FROM stores[*].books[*] AS b WHERE b.price NOT IN (5, `2e0`)", assert:{ evalMode:[EvalModeCoerce, EvalModeError], result:EvaluationSuccess, output:$bag::[ "C", "D", "E", "F" ] } }, { name:"notInPredicateSingleItem", statement:"SELECT VALUE b.title FROM stores[*].books[*] AS b WHERE b.price NOT IN (5)", assert:{ evalMode:[EvalModeCoerce, EvalModeError], result:EvaluationSuccess, output:$bag::[ "B", "C", "D", "E", "F" ] } }, { // expected output is different depending on the TypingMode. Kotlin's LEGACY mode returns false if RHS is not a // bag, list, or sexp name: "notInPredicateSingleExpr", statement: "SELECT VALUE b.title FROM stores[*].books[*] AS b WHERE b.price NOT IN 5", assert: [ { evalMode: EvalModeCoerce, result: EvaluationSuccess, output: $bag::[] }, { evalMode: EvalModeError, result: EvaluationFail } ], }, { name:"notInPredicateSingleItemListVar", statement:"SELECT VALUE b.title FROM stores[*].books[*] AS b WHERE b.price NOT IN (prices)", assert:{ evalMode:[EvalModeCoerce, EvalModeError], result:EvaluationSuccess, output:$bag::[ "A", "B", "C", "D", "A", "E", "F" ] } }, { name:"notInPredicateSingleListVar", statement:"SELECT VALUE b.title FROM stores[*].books[*] AS b WHERE b.price NOT IN prices", assert:{ evalMode:[EvalModeCoerce, EvalModeError], result:EvaluationSuccess, output:$bag::[ "C", "D", "E", "F" ] } }, { name:"notInPredicateSubQuerySelectValue", statement:"SELECT VALUE b.title FROM stores[*].books[*] AS b WHERE b.price NOT IN (SELECT VALUE p FROM prices AS p)", assert:{ evalMode:[EvalModeCoerce, EvalModeError], result:EvaluationSuccess, output:$bag::[ "C", "D", "E", "F" ] } }, { name:"inPredicateWithTableConstructor", statement:"SELECT VALUE b.title FROM stores[*].books[*] AS b WHERE (b.title, b.price) IN (VALUES ('A', `5e0`), ('B', 3.0), ('X', 9.0))", assert:{ evalMode:[EvalModeCoerce, EvalModeError], result:EvaluationSuccess, output:$bag::[ "A", "A" ] } }, { name:"notInPredicateWithTableConstructor", statement:"SELECT VALUE b.title FROM stores[*].books[*] AS b WHERE (b.title, b.price) NOT IN (VALUES ('A', `5e0`), ('B', 3.0), ('X', 9.0))", assert:{ evalMode:[EvalModeCoerce, EvalModeError], result:EvaluationSuccess, output:$bag::[ "B", "C", "D", "E", "F" ] } }, { name:"inPredicateWithExpressionOnRightSide", statement:"SELECT VALUE b.title FROM stores[*].books[*] AS b WHERE 'comedy' IN b.categories", assert:{ evalMode:[EvalModeCoerce, EvalModeError], result:EvaluationSuccess, output:$bag::[ "B", "E" ] } }, { name:"notInPredicateWithExpressionOnRightSide", statement:"SELECT VALUE b.title FROM stores[*].books[*] AS b WHERE 'comedy' NOT IN b.categories", assert:{ evalMode:[EvalModeCoerce, EvalModeError], result:EvaluationSuccess, output:$bag::[ "A", "C", "D", "A", "F" ] } } ]