Skip to content

Commit

Permalink
Fix #88: Parsing issues with large int
Browse files Browse the repository at this point in the history
  • Loading branch information
vishakha041 committed Apr 8, 2019
1 parent a43c982 commit bd89017
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/PMGDQuery.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void PMGDQuery::set_value(const std::string& key, const PMGDProp& p,
break;

case PMGDProp::IntegerType:
prop[key] = (Json::Value::UInt64) p.int_value();
prop[key] = (Json::Value::Int64) p.int_value();
break;

case PMGDProp::StringType:
Expand Down Expand Up @@ -209,7 +209,20 @@ void PMGDQuery::set_property(PMGDProp* p, const std::string& key,
break;

default:
p->set_type(PMGDProp::NoValueType);
// For some reason, Jsoncpp is not parsing a long integer
// and using largest int as mentioned in their specification.
// So large integers come here. Handle that for now and throw
// an exception when we don't know what is going on so we can
// catch it instead of failing silently.
if (val.isInt64()) {
p->set_type(PMGDProp::IntegerType);
p->set_int_value(val.asInt64());
}
else {
printf("%s\n", key.c_str());
throw ExceptionCommand(PMGDTransactiontError,
"Object Type Error");
}
}
}

Expand Down

0 comments on commit bd89017

Please sign in to comment.