8000 fixed issue #14592: IS_NULL(@x) isn't recognized as a constant expression by jsteemann · Pull Request #14605 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

fixed issue #14592: IS_NULL(@x) isn't recognized as a constant expression #14605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
v3.7.15 (XXXX-XX-XX)
--------------------

* Fixed issue #14592: IS_NULL(@x) isn't recognized as a constant expression.

* Fix response when isBuilding could not be removed from newly created
collection, when agency precondition fails. This can happen, when own rebootId
increment has triggered plan entry to be removed (BTS-370).
Expand Down
5 changes: 3 additions & 2 deletions arangod/Aql/Ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3300,8 +3300,9 @@ AstNode* Ast::optimizeFunctionCall(transaction::Methods& trx,
auto args = node->getMember(0);
if (args->numMembers() == 1) {
// replace IS_NULL(x) function call with `x == null`
return createNodeBinaryOperator(NODE_TYPE_OPERATOR_BINARY_EQ,
args->getMemberUnchecked(0), createNodeValueNull());
return this->optimizeBinaryOperatorRelational(trx, aqlFunctionsInternalCache,
createNodeBinaryOperator(NODE_TYPE_OPERATOR_BINARY_EQ,
args->getMemberUnchecked(0), createNodeValueNull()));
}
#if 0
} else if (func->name == "LIKE") {
Expand Down
31 changes: 30 additions & 1 deletion tests/js/server/aql/aql-queries-simple.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*jshint globalstrict:false, strict:false, maxlen: 500 */
/*global assertEqual, AQL_EXECUTE */
/*global assertEqual, assertTrue, assertFalse, AQL_EXECUTE, AQL_EXPLAIN */

////////////////////////////////////////////////////////////////////////////////
/// @brief tests for query language, simple queries
Expand Down Expand Up @@ -1335,6 +1335,35 @@ function ahuacatlQuerySimpleTestSuite () {
});
},

testIsNullConversion : function() {
let q = `RETURN IS_NULL(42)`;
let nodes = AQL_EXPLAIN(q).plan.nodes.filter((n) => n.type === 'CalculationNode');
assertEqual(1, nodes.length);
let expr = nodes[0].expression;
assertEqual("value", expr.type);
assertFalse(expr.value);

q = `RETURN IS_NULL(null)`;
nodes = AQL_EXPLAIN(q).plan.nodes.filter((n) => n.type === 'CalculationNode');
assertEqual(1, nodes.length);
expr = nodes[0].expression;
assertEqual("value", expr.type);
assertTrue(expr.value);

q = `RETURN IS_NULL(@value)`;
nodes = AQL_EXPLAIN(q, {value: 42}).plan.nodes.filter((n) => n.type === 'CalculationNode');
assertEqual(1, nodes.length);
expr = nodes[0].expression;
assertEqual("value", expr.type);
assertFalse(expr.value);

nodes = AQL_EXPLAIN(q, {value: null}).plan.nodes.filter((n) => n.type === 'CalculationNode');
assertEqual(1, nodes.length);
expr = nodes[0].expression;
assertEqual("value", expr.type);
assertTrue(expr.value);
},

};
}

Expand Down
0