Skip to content

Commit

Permalink
Return "missing property" when getting results as list
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishakha Gupta-Cledat committed Apr 26, 2018
1 parent 9e37069 commit 9f385f8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/PMGDQueryHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,12 @@ void PMGDQueryHandler::build_results(Iterator &ni,
for (; ni; ni.next()) {
for (int i = 0; i < keyids.size(); ++i) {
Property j_p;
if (!ni->check_property(keyids[i], j_p))
continue;
PMGDPropList &list = rmap[qn.response_keys(i)];
PMGDProp *p_p = list.add_values();
if (!ni->check_property(keyids[i], j_p)) {
construct_missing_property(p_p);
continue;
}
construct_protobuf_property(j_p, p_p);
}
count++;
Expand Down Expand Up @@ -584,3 +586,10 @@ void PMGDQueryHandler::construct_protobuf_property(const Property &j_p, PMGDProp
p_p->set_blob_value(j_p.blob_value().value, j_p.blob_value().size);
}
}

void PMGDQueryHandler::construct_missing_property(PMGDProp *p_p)
{
// Assumes matching enum values!
p_p->set_type(PMGDProp::StringType);
p_p->set_string_value("Missing property");
}
1 change: 1 addition & 0 deletions src/PMGDQueryHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ namespace VDMS {
const PMGDQueryNode &qn,
PMGDCmdResponse *response);
void construct_protobuf_property(const PMGD::Property &j_p, PMGDProp*p_p);
void construct_missing_property(PMGDProp *p_p);

void set_response(PMGDCmdResponse *response, PMGDCmdErrorCode error_code,
std::string error_msg)
Expand Down
2 changes: 1 addition & 1 deletion tests/AddAndFind_query.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
"Age": [">", 0, "<=", 100 ]
},
"results": {
"list":["Name","Age","Email"],
"list":["Name","Age","Email", "Study"],
"sort" :"Age"
}
}
Expand Down
10 changes: 9 additions & 1 deletion tests/json_queries.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,15 @@ TEST(QueryHandler, AddAndFind){
if (cmd =="FindEntity")
out_query_num++;

if (j == 12) { // Last FindEntiyu
if (j == 11) { // Second Last FindEntity
EXPECT_EQ(query["FindEntity"]["entities"][2]["Study"].asString(),
"Missing property");

EXPECT_EQ(query["FindEntity"]["entities"][3]["Study"].asString(),
"Missing property");
}

if (j == 12) { // Last FindEntiy
EXPECT_EQ(query["FindEntity"]["entities"][0]["Birthday"].asString(),
"1946-10-07T17:59:24-07:00");

Expand Down

0 comments on commit 9f385f8

Please sign in to comment.