Return properties as a list in SHOW CONSTRAINT INFO
for unique constraints
Summary: Before this change properties were joined by ", " and returned as a single string, which was ambiguous for properties that contain ", ". This diff solves this problem by returning properties as a list type. Reviewers: mferencevic Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2778
This commit is contained in:
parent
d36da12b48
commit
3932376301
@ -833,14 +833,14 @@ PreparedQuery PrepareInfoQuery(
|
||||
TypedValue(db->PropertyToName(item.second))});
|
||||
}
|
||||
for (const auto &item : info.unique) {
|
||||
std::stringstream properties;
|
||||
utils::PrintIterable(properties, item.second, ", ",
|
||||
[&db](auto &stream, const auto &entry) {
|
||||
stream << db->PropertyToName(entry);
|
||||
});
|
||||
std::vector<TypedValue> properties;
|
||||
properties.reserve(item.second.size());
|
||||
for (const auto &property : item.second) {
|
||||
properties.emplace_back(db->PropertyToName(property));
|
||||
}
|
||||
results.push_back({TypedValue("unique"),
|
||||
TypedValue(db->LabelToName(item.first)),
|
||||
TypedValue(properties.str())});
|
||||
TypedValue(std::move(properties))});
|
||||
}
|
||||
return std::pair{results, QueryHandlerResult::NOTHING};
|
||||
};
|
||||
|
@ -402,7 +402,10 @@ TEST_F(InterpreterTest, UniqueConstraintTest) {
|
||||
ASSERT_EQ(result.size(), 3U);
|
||||
ASSERT_EQ(result[0].ValueString(), "unique");
|
||||
ASSERT_EQ(result[1].ValueString(), "A");
|
||||
ASSERT_EQ(result[2].ValueString(), "a, b");
|
||||
const auto &properties = result[2].ValueList();
|
||||
ASSERT_EQ(properties.size(), 2U);
|
||||
ASSERT_EQ(properties[0].ValueString(), "a");
|
||||
ASSERT_EQ(properties[1].ValueString(), "b");
|
||||
}
|
||||
|
||||
// Drop constraint.
|
||||
|
Loading…
Reference in New Issue
Block a user