Files
scylladb/cql3/assignment_testable.hh
Avi Kivity 665429d85b cql3: remove assignment_testable::test_all
Was replaced with cql3::expr::test_assignment_all().

Closes #12951
2023-02-23 12:50:05 +01:00

68 lines
1.9 KiB
C++

/*
* Copyright (C) 2014-present ScyllaDB
*
* Modified by ScyllaDB
*/
/*
* SPDX-License-Identifier: (AGPL-3.0-or-later and Apache-2.0)
*/
#pragma once
#include "column_specification.hh"
#include "data_dictionary/data_dictionary.hh"
#include <memory>
#include <vector>
namespace cql3 {
class assignment_testable {
public:
virtual ~assignment_testable() {}
enum class test_result {
EXACT_MATCH,
WEAKLY_ASSIGNABLE,
NOT_ASSIGNABLE,
};
static bool is_assignable(test_result tr) {
return tr != test_result::NOT_ASSIGNABLE;
}
static bool is_exact_match(test_result tr) {
return tr != test_result::EXACT_MATCH;
}
/**
* @return whether this object can be assigned to the provided receiver. We distinguish
* between 3 values:
* - EXACT_MATCH if this object is exactly of the type expected by the receiver
* - WEAKLY_ASSIGNABLE if this object is not exactly the expected type but is assignable nonetheless
* - NOT_ASSIGNABLE if it's not assignable
* Most caller should just call the isAssignable() method on the result, though functions have a use for
* testing "strong" equality to decide the most precise overload to pick when multiple could match.
*/
virtual test_result test_assignment(data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) const = 0;
// for error reporting
virtual sstring assignment_testable_source_context() const = 0;
};
inline bool is_assignable(assignment_testable::test_result tr) {
return assignment_testable::is_assignable(tr);
}
inline bool is_exact_match(assignment_testable::test_result tr) {
return assignment_testable::is_exact_match(tr);
}
inline
std::ostream&
operator<<(std::ostream& os, const assignment_testable& at) {
return os << at.assignment_testable_source_context();
}
}