column_expression progress
This commit is contained in:
@@ -256,9 +256,9 @@ public:
|
||||
template<typename Type>
|
||||
void push_back(const char* id, const Type& value) {
|
||||
if (is_column_value_generator_option_set(options_, column_value_generator_options::ValuesAsPlaceHolder)) {
|
||||
result_.emplace_back(id, utils::_);
|
||||
result_.emplace_back(id, std::make_unique<placeholder_expression>());
|
||||
} else {
|
||||
result_.emplace_back(id, value);
|
||||
result_.emplace_back(id, std::make_unique<value_expression>(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,21 +11,22 @@ namespace matador::query::internal {
|
||||
|
||||
class column_value_pair {
|
||||
public:
|
||||
column_value_pair(table_column col, utils::database_type value);
|
||||
column_value_pair(const std::string& name, utils::database_type value);
|
||||
column_value_pair(const char *name, utils::database_type value);
|
||||
column_value_pair(const char *name, utils::placeholder p);
|
||||
// column_value_pair(table_column col, utils::database_type value);
|
||||
// column_value_pair(const std::string& name, utils::database_type value);
|
||||
// column_value_pair(const char *name, utils::database_type value);
|
||||
// column_value_pair(const char *name, utils::placeholder p);
|
||||
column_value_pair(table_column col, column_expression_ptr expression);
|
||||
|
||||
friend bool operator==(const column_value_pair &lhs, const column_value_pair &rhs);
|
||||
friend bool operator!=(const column_value_pair &lhs, const column_value_pair &rhs);
|
||||
|
||||
[[nodiscard]] const table_column& col() const;
|
||||
[[nodiscard]] const std::variant<utils::placeholder, utils::database_type>& value() const;
|
||||
// [[nodiscard]] const std::variant<utils::placeholder, utils::database_type>& value() const;
|
||||
[[nodiscard]] const abstract_column_expression& expression() const;
|
||||
|
||||
private:
|
||||
table_column column_;
|
||||
std::variant<utils::placeholder, utils::database_type> value_;
|
||||
// std::variant<utils::placeholder, utils::database_type> value_;
|
||||
column_expression_ptr expression_;
|
||||
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
void on_primary_key(const char *id, V &x, const utils::primary_key_attribute& /*attr*/ = utils::default_pk_attributes) {
|
||||
result_.emplace_back(id, x);
|
||||
}
|
||||
void on_revision(const char *id, uint64_t &/*rev*/);
|
||||
void on_revision(const char *id, uint64_t &/*rev*/) const;
|
||||
|
||||
template<typename Type>
|
||||
void on_attribute(const char *id, Type &x, const utils::field_attributes &/*attr*/ = utils::null_attributes) {
|
||||
|
||||
@@ -22,18 +22,18 @@ public:
|
||||
table_column(const std::string& name, const std::string& alias);
|
||||
table_column(sql::sql_function_t func, const std::string& name);
|
||||
table_column(const class table* tab, const std::string& name);
|
||||
table_column(const class table* tab, const std::string& name,
|
||||
const std::string& alias);
|
||||
table_column(const class table* tab, const std::string& name, const std::string& alias);
|
||||
table_column(const class table* tab, const std::string& name, utils::basic_type type, const utils::field_attributes& attributes);
|
||||
table_column(const class table*,
|
||||
const std::string& name,
|
||||
std::string alias,
|
||||
utils::basic_type type,
|
||||
const utils::field_attributes& attributes,
|
||||
sql::sql_function_t func = sql::sql_function_t::None);
|
||||
sql::sql_function_t func = sql::sql_function_t::None,
|
||||
const std::shared_ptr<abstract_column_expression>& expression = {});
|
||||
|
||||
|
||||
table_column(column_expression_ptr expression) noexcept;
|
||||
table_column(const std::shared_ptr<abstract_column_expression>& expression) noexcept;
|
||||
table_column& operator=(const table_column& other);
|
||||
table_column(const table_column& other) = default;
|
||||
table_column(table_column&& other) noexcept = default;
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
|
||||
// New: expression-backed column support
|
||||
[[nodiscard]] bool is_expression() const;
|
||||
[[nodiscard]] const column_expression_ptr& expression() const;
|
||||
[[nodiscard]] std::shared_ptr<abstract_column_expression> expression() const;
|
||||
|
||||
// ReSharper disable once CppNonExplicitConversionOperator
|
||||
operator const std::string&() const; // NOLINT(*-explicit-constructor)
|
||||
@@ -116,7 +116,7 @@ private:
|
||||
|
||||
sql::sql_function_t function_{sql::sql_function_t::None};
|
||||
|
||||
column_expression_ptr expression_{};
|
||||
std::shared_ptr<abstract_column_expression> expression_;
|
||||
};
|
||||
|
||||
table_column operator ""_col(const char *name, size_t len);
|
||||
|
||||
Reference in New Issue
Block a user