Add multiple properties unique constraint

Summary:
Unique constraint now support multiple properties

Depends on D2043

Reviewers: ipaljak, mferencevic, vkasljevic

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2044
This commit is contained in:
Matija Santl
2019-05-13 15:26:56 +02:00
parent 1e79313538
commit 37c68f0508
29 changed files with 942 additions and 1301 deletions

View File

@@ -303,3 +303,51 @@ TEST_F(InterpreterTest, ShortestPath) {
EXPECT_TRUE(any_match);
}
}
// NOLINTNEXTLINE(hicpp-special-member-functions)
TEST_F(InterpreterTest, UniqueConstraintTest) {
ResultStreamFaker<query::TypedValue> stream;
{
auto dba = db_.Access();
interpreter_("CREATE CONSTRAINT ON (n:A) ASSERT n.a, n.b IS UNIQUE;", dba,
{}, true)
.PullAll(stream);
dba.Commit();
}
{
auto dba = db_.Access();
interpreter_("CREATE (:A{a:1, b:1})", dba, {}, true).PullAll(stream);
dba.Commit();
}
{
auto dba = db_.Access();
interpreter_("CREATE (:A{a:2, b:2})", dba, {}, true).PullAll(stream);
dba.Commit();
}
{
auto dba = db_.Access();
ASSERT_THROW(
interpreter_("CREATE (:A{a:1, b:1})", dba, {}, true).PullAll(stream),
query::QueryRuntimeException);
dba.Commit();
}
{
auto dba = db_.Access();
interpreter_("MATCH (n:A{a:2, b:2}) SET n.a=1", dba, {}, true)
.PullAll(stream);
interpreter_("CREATE (:A{a:2, b:2})", dba, {}, true).PullAll(stream);
dba.Commit();
}
{
auto dba = db_.Access();
interpreter_("MATCH (n:A{a:2, b:2}) DETACH DELETE n", dba, {}, true)
.PullAll(stream);
interpreter_("CREATE (n:A{a:2, b:2})", dba, {}, true).PullAll(stream);
dba.Commit();
}
}