Query::Plan::EdgeFilter bugfix
Summary: Resolved the bug where edge filters with no edge-types dont accept any edge. Illustrated with the following queries: CREATE ()-[]->() MATCH ()-[]->() (produces 0 results, expected 1) Reviewers: mislav.bradac Reviewed By: mislav.bradac Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D265
This commit is contained in:
parent
355b9a9b9a
commit
ea202dc52a
@ -427,8 +427,8 @@ bool EdgeFilter::EdgeFilterCursor::EdgePasses(const EdgeAccessor &edge,
|
|||||||
// edge type filtering - logical OR
|
// edge type filtering - logical OR
|
||||||
const auto &types = self_.edge_atom_->edge_types_;
|
const auto &types = self_.edge_atom_->edge_types_;
|
||||||
GraphDbTypes::EdgeType type = edge.edge_type();
|
GraphDbTypes::EdgeType type = edge.edge_type();
|
||||||
if (!std::any_of(types.begin(), types.end(),
|
if (types.size() && std::none_of(types.begin(), types.end(),
|
||||||
[type](auto t) { return t == type; }))
|
[type](auto t) { return t == type; }))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ExpressionEvaluator expression_evaluator(frame, symbol_table);
|
ExpressionEvaluator expression_evaluator(frame, symbol_table);
|
||||||
|
@ -388,6 +388,26 @@ TEST(QueryPlan, EdgeFilter) {
|
|||||||
EXPECT_EQ(result.GetResults().size(), 1);
|
EXPECT_EQ(result.GetResults().size(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(QueryPlan, EdgeFilterEmpty) {
|
||||||
|
Dbms dbms;
|
||||||
|
auto dba = dbms.active();
|
||||||
|
|
||||||
|
auto v1 = dba->insert_vertex();
|
||||||
|
auto v2 = dba->insert_vertex();
|
||||||
|
dba->insert_edge(v1, v2, dba->edge_type("type"));
|
||||||
|
dba->advance_command();
|
||||||
|
|
||||||
|
AstTreeStorage storage;
|
||||||
|
SymbolTable symbol_table;
|
||||||
|
|
||||||
|
auto n = MakeScanAll(storage, symbol_table, "n");
|
||||||
|
auto r_m = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r",
|
||||||
|
EdgeAtom::Direction::RIGHT, false, "m", false);
|
||||||
|
auto edge_filter =
|
||||||
|
std::make_shared<EdgeFilter>(r_m.op_, r_m.edge_sym_, r_m.edge_);
|
||||||
|
EXPECT_EQ(1, PullAll(edge_filter, *dba, symbol_table));
|
||||||
|
}
|
||||||
|
|
||||||
TEST(QueryPlan, EdgeFilterMultipleTypes) {
|
TEST(QueryPlan, EdgeFilterMultipleTypes) {
|
||||||
Dbms dbms;
|
Dbms dbms;
|
||||||
auto dba = dbms.active();
|
auto dba = dbms.active();
|
||||||
|
Loading…
Reference in New Issue
Block a user