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

Skip to content

Commit a7ca8e1

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

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
v3.7.14 (XXXX-XX-XX)
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 cases
57
and numerically unstable behaviour. In particular, the case of the
68
intersection of two polygons in which one is an S2LngLatRect is fixed

arangod/Aql/Ast.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3300,8 +3300,9 @@ AstNode* Ast::optimizeFunctionCall(transaction::Methods& trx,
33003300
auto args = node->getMember(0);
33013301
if (args->numMembers() == 1) {
33023302
// replace IS_NULL(x) function call with `x == null`
3303-
return createNodeBinaryOperator(NODE_TYPE_OPERATOR_BINARY_EQ,
3304-
args->getMemberUnchecked(0), createNodeValueNull());
3303+
return this->optimizeBinaryOperatorRelational(trx, aqlFunctionsInternalCache,
3304+
createNodeBinaryOperator(NODE_TYPE_OPERATOR_BINARY_EQ,
3305+
args->getMemberUnchecked(0), createNodeValueNull()));
33053306
}
33063307
#if 0
33073308
} else if (func->name == "LIKE") {

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

Lines changed: 30 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
@@ -1335,6 +1335,35 @@ function ahuacatlQuerySimpleTestSuite () {
13351335
});
13361336
},
13371337

1338+
testIsNullConversion : function() {
1339+
let q = `RETURN IS_NULL(42)`;
1340+
let nodes = AQL_EXPLAIN(q).plan.nodes.filter((n) => n.type === 'CalculationNode');
1341+
assertEqual(1, nodes.length);
1342+
let expr = nodes[0].expression;
1343+
assertEqual("value", expr.type);
1344+
assertFalse(expr.value);
1345+
1346+
q = `RETURN IS_NULL(null)`;
1347+
nodes = AQL_EXPLAIN(q).plan.nodes.filter((n) => n.type === 'CalculationNode');
1348+
assertEqual(1, nodes.length);
1349+
expr = nodes[0].expression;
1350+
assertEqual("value", expr.type);
1351+
assertTrue(expr.value);
1352+
1353+
q = `RETURN IS_NULL(@value)`;
1354+
nodes = AQL_EXPLAIN(q, {value: 42}).plan.nodes.filter((n) => n.type === 'CalculationNode');
1355+
assertEqual(1, nodes.length);
1356+
expr = nodes[0].expression;
1357+
assertEqual("value", expr.type);
1358+
assertFalse(expr.value);
1359+
1360+
nodes = AQL_EXPLAIN(q, {value: null}).plan.nodes.filter((n) => n.type === 'CalculationNode');
1361+
assertEqual(1, nodes.length);
1362+
expr = nodes[0].expression;
1363+
assertEqual("value", expr.type);
1364+
assertTrue(expr.value);
1365+
},
1366+
13381367
};
13391368
}
13401369

0 commit comments

Comments
 (0)
0