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 a96c183
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 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

0 comments on commit a96c183

Please sign in to comment.