1
0
Fork 0

bug in increment and decrement in agency solved.

This commit is contained in:
Kaveh Vahedipour 2016-03-29 15:09:58 +02:00
parent 43749f1f52
commit 19267cbbac
1 changed files with 6 additions and 18 deletions

View File

@ -209,36 +209,24 @@ bool Node::applies (VPackSlice const& slice) {
*this = slice.get("new");
return true;
} else if (oper == "increment") { // Increment
/* if (!(self.isInt() || self.isUInt())) {
LOG_TOPIC(WARN, Logger::AGENCY)
<< "Element to increment must be integral type: We are "
<< self.toJson();
return false;
}*/
Builder tmp;
try {
Builder tmp;
tmp.add(Value(self.isInt() ? int64_t(self.getInt()+1) :
uint64_t(self.getUInt()+1)));
*this = tmp.slice();
} catch (std::exception const& e) {
return false;
tmp.add(Value(1));
}
*this = tmp.slice();
return true;
} else if (oper == "decrement") { // Decrement
/* if (!(self.isInt() || self.isUInt())) {
LOG_TOPIC(WARN, Logger::AGENCY)
<< "Element to decrement must be integral type. We are "
<< self.toJson();
return false;
}*/
Builder tmp;
try {
Builder tmp;
tmp.add(Value(self.isInt() ? int64_t(self.getInt()-1) :
uint64_t(self.getUInt()-1)));
*this = tmp.slice();
} catch (std::exception const& e) {
return false;
tmp.add(Value(-1));
}
*this = tmp.slice();
return true;
} else if (oper == "push") { // Push
if (!slice.hasKey("new")) {