From 0ed01acf1551f59c597bca048c586a18eb3bcc57 Mon Sep 17 00:00:00 2001 From: Duarte Nunes Date: Thu, 27 Sep 2018 23:32:00 +0100 Subject: [PATCH] cql3/selection/selector: Unwrap types when validating assignment When validating assignment between two types, it's possible one of them is wrapped in a reverse_type, if it comes, for example, from the type associated with a clustering column. When checking for weak assignment the types are correctly unwrapped, but not when checking for an exact match, which this patch fixes. Technically, the receiver is never a reversed_type for the current callers, but this is the morally correct implementation, as the type being reversed or not plays no role in assignment. Tests: unit(release) Fixes #3789 Signed-off-by: Duarte Nunes Message-Id: <20180927223201.28152-1-duarte@scylladb.com> (cherry picked from commit 5e7bb20c8a91006e549015d2b3fcb8ff50ce86d7) --- cql3/selection/selector.hh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cql3/selection/selector.hh b/cql3/selection/selector.hh index f0e326786b..e6ff4d39cd 100644 --- a/cql3/selection/selector.hh +++ b/cql3/selection/selector.hh @@ -105,9 +105,11 @@ public: virtual void reset() = 0; virtual assignment_testable::test_result test_assignment(database& db, const sstring& keyspace, ::shared_ptr receiver) override { - if (receiver->type == get_type()) { + auto t1 = receiver->type->underlying_type(); + auto t2 = get_type()->underlying_type(); + if (t1 == t2) { return assignment_testable::test_result::EXACT_MATCH; - } else if (receiver->type->is_value_compatible_with(*get_type())) { + } else if (t1->is_value_compatible_with(*t2)) { return assignment_testable::test_result::WEAKLY_ASSIGNABLE; } else { return assignment_testable::test_result::NOT_ASSIGNABLE;