From 9d1cd2c57b53d259da32587e04b19efcde0a7ff1 Mon Sep 17 00:00:00 2001 From: Piotr Grabowski Date: Thu, 15 Oct 2020 11:52:52 +0200 Subject: [PATCH] token_restriction: Add non-token merge exception Add exception that is thrown when merging of token and non-token restrictions is attempted. Before this change only merging non-token and token restriction was validated (WHERE pk = 0 AND token(pk) > 0) and not the other way (WHERE token(pk) > 0 AND pk = 0). --- cql3/restrictions/token_restriction.hh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cql3/restrictions/token_restriction.hh b/cql3/restrictions/token_restriction.hh index 59855b6996..9136cf4307 100644 --- a/cql3/restrictions/token_restriction.hh +++ b/cql3/restrictions/token_restriction.hh @@ -71,6 +71,11 @@ public: } void merge_with(::shared_ptr restriction) override { + if (!has_token(restriction->expression)) { + throw exceptions::invalid_request_exception( + format("Columns \"{}\" cannot be restricted by both a normal relation and a token relation", + join(", ", get_column_defs()))); + } expression = make_conjunction(std::move(expression), restriction->expression); }