tests/cql3: add tests for multi column relations

Signed-off-by: Paweł Dziepak <pdziepak@cloudius-systems.com>
This commit is contained in:
Paweł Dziepak
2015-08-04 10:35:17 +02:00
parent 0069040eb3
commit 77dd2faee0

View File

@@ -1554,3 +1554,82 @@ SEASTAR_TEST_CASE(test_order_by_validate) {
});
});
}
SEASTAR_TEST_CASE(test_multi_column_restrictions) {
return do_with_cql_env([] (auto& e) {
return e.execute_cql("create table tmcr (p1 int, c1 int, c2 int, c3 int, r1 int, PRIMARY KEY (p1, c1, c2, c3));").discard_result().then([&e] {
e.require_table_exists("ks", "tmcr");
return e.execute_cql("insert into tmcr (p1, c1, c2, c3, r1) values (0, 0, 0, 0, 0);").discard_result();
}).then([&e] {
return e.execute_cql("insert into tmcr (p1, c1, c2, c3, r1) values (0, 0, 0, 1, 1);").discard_result();
}).then([&e] {
return e.execute_cql("insert into tmcr (p1, c1, c2, c3, r1) values (0, 0, 1, 0, 2);").discard_result();
}).then([&e] {
return e.execute_cql("insert into tmcr (p1, c1, c2, c3, r1) values (0, 0, 1, 1, 3);").discard_result();
}).then([&e] {
return e.execute_cql("insert into tmcr (p1, c1, c2, c3, r1) values (0, 1, 0, 0, 4);").discard_result();
}).then([&e] {
return e.execute_cql("insert into tmcr (p1, c1, c2, c3, r1) values (0, 1, 0, 1, 5);").discard_result();
}).then([&e] {
return e.execute_cql("insert into tmcr (p1, c1, c2, c3, r1) values (0, 1, 1, 0, 6);").discard_result();
}).then([&e] {
return e.execute_cql("insert into tmcr (p1, c1, c2, c3, r1) values (0, 1, 1, 1, 7);").discard_result();
}).then([&e] {
return e.execute_cql("select r1 from tmcr where p1 = 0 and (c1, c2, c3) = (0, 1, 1);");
}).then([&e] (auto msg) {
assert_that(msg).is_rows().with_rows({
{int32_type->decompose(3)},
});
return e.execute_cql("select r1 from tmcr where p1 = 0 and (c1, c2) = (0, 1);");
}).then([&e] (auto msg) {
assert_that(msg).is_rows().with_rows({
{int32_type->decompose(2)},
{int32_type->decompose(3)},
});
return e.execute_cql("select r1 from tmcr where p1 = 0 and (c1, c2, c3) in ((0, 1, 0), (1, 0, 1), (0, 1, 0));");
}).then([&e] (auto msg) {
assert_that(msg).is_rows().with_rows({
{int32_type->decompose(2)},
{int32_type->decompose(5)},
{int32_type->decompose(2)},
});
return e.execute_cql("select r1 from tmcr where p1 = 0 and (c1, c2) in ((0, 1), (1, 0), (0, 1));");
}).then([&e] (auto msg) {
assert_that(msg).is_rows().with_rows({
{int32_type->decompose(2)},
{int32_type->decompose(3)},
{int32_type->decompose(4)},
{int32_type->decompose(5)},
{int32_type->decompose(2)},
{int32_type->decompose(3)},
});
return e.execute_cql("select r1 from tmcr where p1 = 0 and (c1, c2, c3) >= (1, 0, 1);");
}).then([&e] (auto msg) {
assert_that(msg).is_rows().with_rows({
{int32_type->decompose(5)},
{int32_type->decompose(6)},
{int32_type->decompose(7)},
});
return e.execute_cql("select r1 from tmcr where p1 = 0 and (c1, c2, c3) >= (0, 1, 1) and (c1, c2, c3) < (1, 1, 0);");
}).then([&e] (auto msg) {
assert_that(msg).is_rows().with_rows({
{int32_type->decompose(3)},
{int32_type->decompose(4)},
{int32_type->decompose(5)},
});
return e.execute_cql("select r1 from tmcr where p1 = 0 and (c1, c2) >= (0, 1) and (c1, c2, c3) < (1, 0, 1);");
}).then([&e] (auto msg) {
assert_that(msg).is_rows().with_rows({
{int32_type->decompose(2)},
{int32_type->decompose(3)},
{int32_type->decompose(4)},
});
return e.execute_cql("select r1 from tmcr where p1 = 0 and (c1, c2, c3) > (0, 1, 0) and (c1, c2) <= (0, 1);");
}).then([&e] (auto msg) {
assert_that(msg).is_rows().with_rows({
{int32_type->decompose(3)},
});
});
});
}