mirror of https://gitee.com/bigwinds/arangodb
added unary operator
This commit is contained in:
parent
9f08e441fd
commit
ae5f454bfc
|
@ -664,6 +664,10 @@ bool AstNode::isSimple () const {
|
|||
return (getMember(0)->isSimple() && getMember(1)->isSimple());
|
||||
}
|
||||
|
||||
if (type == NODE_TYPE_OPERATOR_UNARY_NOT) {
|
||||
return getMember(0)->isSimple();
|
||||
}
|
||||
|
||||
if (type == NODE_TYPE_FCALL) {
|
||||
// some functions have C++ handlers
|
||||
// check if the called function is one of them
|
||||
|
|
|
@ -404,6 +404,22 @@ AqlValue Expression::executeSimpleExpression (AstNode const* node,
|
|||
return res;
|
||||
}
|
||||
|
||||
else if (node->type == NODE_TYPE_OPERATOR_UNARY_NOT) {
|
||||
TRI_document_collection_t const* myCollection = nullptr;
|
||||
AqlValue operand = executeSimpleExpression(node->getMember(0), &myCollection, trx, docColls, argv, startPos, vars, regs);
|
||||
|
||||
bool operandIsBoolean = operand.isBoolean();
|
||||
bool operandIsTrue = operand.isTrue();
|
||||
|
||||
operand.destroy();
|
||||
|
||||
if (! operandIsBoolean) {
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_QUERY_INVALID_LOGICAL_VALUE);
|
||||
}
|
||||
|
||||
return AqlValue(new triagens::basics::Json(! operandIsTrue));
|
||||
}
|
||||
|
||||
else if (node->type == NODE_TYPE_OPERATOR_BINARY_AND ||
|
||||
node->type == NODE_TYPE_OPERATOR_BINARY_OR) {
|
||||
TRI_document_collection_t const* leftCollection = nullptr;
|
||||
|
|
Loading…
Reference in New Issue