@@ -444,6 +444,12 @@ AqlValue Expression::executeSimpleExpression(
444
444
regs, mustDestroy);
445
445
case NODE_TYPE_OPERATOR_UNARY_NOT:
446
446
return executeSimpleExpressionNot (node, trx, argv, startPos, vars, regs, mustDestroy);
447
+
448
+ case NODE_TYPE_OPERATOR_UNARY_PLUS:
449
+ return executeSimpleExpressionPlus (node, trx, argv, startPos, vars, regs, mustDestroy);
450
+
451
+ case NODE_TYPE_OPERATOR_UNARY_MINUS:
452
+ return executeSimpleExpressionMinus (node, trx, argv, startPos, vars, regs, mustDestroy);
447
453
448
454
case NODE_TYPE_OPERATOR_BINARY_AND:
449
455
case NODE_TYPE_OPERATOR_BINARY_OR:
@@ -947,6 +953,70 @@ AqlValue Expression::executeSimpleExpressionNot(
947
953
return AqlValue (!operandIsTrue);
948
954
}
949
955
956
+ // / @brief execute an expression of type SIMPLE with +
957
+ AqlValue Expression::executeSimpleExpressionPlus (
958
+ AstNode const * node, arangodb::AqlTransaction* trx,
959
+ AqlItemBlock const * argv, size_t startPos,
960
+ std::vector<Variable const *> const & vars,
961
+ std::vector<RegisterId> const & regs, bool & mustDestroy) {
962
+
963
+ mustDestroy = false ;
964
+ AqlValue operand =
965
+ executeSimpleExpression (node->getMember (0 ), trx, argv,
966
+ startPos, vars, regs, mustDestroy, false );
967
+
968
+ AqlValueGuard guard (operand, mustDestroy);
969
+
970
+ bool failed = false ;
971
+ double value = operand.toDouble (trx, failed);
972
+
973
+ if (failed) {
974
+ value = 0.0 ;
975
+ }
976
+
977
+ double result = +value;
978
+ if (std::isnan (result) || !std::isfinite (result) || result == HUGE_VAL || result == -HUGE_VAL) {
979
+ return AqlValue (VelocyPackHelper::NullValue ());
980
+ }
981
+
982
+ TransactionBuilderLeaser builder (trx);
983
+ mustDestroy = true ; // builder = dynamic data
984
8000
td>+ builder->add (VPackValue (result));
985
+ return AqlValue (*builder.get ());
986
+ }
987
+
988
+ // / @brief execute an expression of type SIMPLE with -
989
+ AqlValue Expression::executeSimpleExpressionMinus (
990
+ AstNode const * node, arangodb::AqlTransaction* trx,
991
+ AqlItemBlock const * argv, size_t startPos,
992
+ std::vector<Variable const *> const & vars,
993
+ std::vector<RegisterId> const & regs, bool & mustDestroy) {
994
+
995
+ mustDestroy = false ;
996
+ AqlValue operand =
997
+ executeSimpleExpression (node->getMember (0 ), trx, argv,
998
+ startPos, vars, regs, mustDestroy, false );
999
+
1000
+ AqlValueGuard guard (operand, mustDestroy);
1001
+
1002
+ bool failed = false ;
1003
+ double value = operand.toDouble (trx, failed);
1004
+
1005
+ if (failed) {
1006
+ value = 0.0 ;
1007
+ }
1008
+
1009
+ double result = -value;
1010
+ if (std::isnan (result) || !std::isfinite (result) || result == HUGE_VAL || result == -HUGE_VAL) {
1011
+ return AqlValue (VelocyPackHelper::NullValue ());
1012
+ }
1013
+
1014
+ TransactionBuilderLeaser builder (trx);
1015
+ mustDestroy = true ; // builder = dynamic data
1016
+ builder->add (VPackValue (result));
1017
+ return AqlValue (*builder.get ());
1018
+ }
1019
+
950
1020
// / @brief execute an expression of type SIMPLE with AND or OR
951
1021
AqlValue Expression::executeSimpleExpressionAndOr (
952
1022
AstNode const * node, arangodb::AqlTransaction* trx,
0 commit comments