8000 fixed issue #14592: IS_NULL(@x) isn't recognized as a constant expres… · arangodb/arangodb@39cffa6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 39cffa6

Browse files
committed
fixed issue #14592: IS_NULL(@x) isn't recognized as a constant expression
1 parent d7b6fed commit 39cffa6

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
devel
22
-----
33

4+
* Fixed issue #14592: IS_NULL(@x) isn't recognized as a constant expression.
5+
46
* Fixed various problems in GEO_INTERSECTS: wrong results, not implemented
57
cases and numerically unstable behaviour. In particular, the case of
68
the intersection of two polygons in which one is an S2LngLatRect

arangod/Aql/Ast.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3480,8 +3480,9 @@ AstNode* Ast::optimizeFunctionCall(transaction::Methods& trx,
34803480
auto args = node->getMember(0);
34813481
if (args->numMembers() == 1) {
34823482
// replace IS_NULL(x) function call with `x == null`
3483-
return createNodeBinaryOperator(NODE_TYPE_OPERATOR_BINARY_EQ,
3484-
args->getMemberUnchecked(0), createNodeValueNull());
3483+
return this->optimizeBinaryOperatorRelational(trx, aqlFunctionsInternalCache,
3484+
createNodeBinaryOperator(NODE_TYPE_OPERATOR_BINARY_EQ,
3485+
args->getMemberUnchecked(0), createNodeValueNull()));
34853486
}
34863487
#if 0
34873488
} else if (func->name == "LIKE") {

tests/js/server/aql/aql-queries-simple.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*jshint globalstrict:false, strict:false, maxlen: 500 */
2-
/*global assertEqual, AQL_EXECUTE */
2+
/*global assertEqual, assertTrue, assertFalse, AQL_EXECUTE, AQL_EXPLAIN */
33

44
////////////////////////////////////////////////////////////////////////////////
55
/// @brief tests for query language, simple queries
@@ -1406,6 +1406,36 @@ function ahuacatlQuerySimpleTestSuite () {
14061406
}
14071407
assertQueryError(errors.ERROR_QUERY_TOO_MUCH_NESTING.code, q);
14081408
},
1409+
1410+
testIsNullConversion : function() {
1411+
let q = `RETURN IS_NULL(42)`;
1412+
let nodes = AQL_EXPLAIN(q).plan.nodes.filter((n) => n.type === 'CalculationNode');
1413+
assertEqual(1, nodes.length);
1414+
let expr = nodes[0].expression;
1415+
assertEqual("value", expr.type);
1416+
assertFalse(expr.value);
1417+
1418+
q = `RETURN IS_NULL(null)`;
1419+
nodes = AQL_EXPLAIN(q).plan.nodes.filter((n) => n.type === 'CalculationNode');
1420+
assertEqual(1, nodes.length);
1421+
expr = nodes[0].expression;
1422+
assertEqual("value", expr.type);
1423+
assertTrue(expr.value);
1424+
1425+
q = `RETURN IS_NULL(@value)`;
1426+
nodes = AQL_EXPLAIN(q, {value: 42}).plan.nodes.filter((n) => n.type === 'CalculationNode');
1427+
assertEqual(1, nodes.length);
1428+
expr = nodes[0].expression;
1429+
assertEqual("value", expr.type);
1430+
assertFalse(expr.value);
1431+
1432+
nodes = AQL_EXPLAIN(q, {value: null}).plan.nodes.filter((n) => n.type === 'CalculationNode');
1433+
assertEqual(1, nodes.length);
1434+
expr = nodes[0].expression;
1435+
assertEqual("value", expr.type);
1436+
assertTrue(expr.value);
1437+
},
1438+
14091439
};
14101440
}
14111441

0 commit comments

Comments
 (0)
0