some column interface refactorings
This commit is contained in:
@@ -302,7 +302,7 @@ utils::result<object::object_ptr<Type>, utils::error> session::find(const Primar
|
||||
const auto& type_info = info.value().get();
|
||||
|
||||
session_query_builder eqb(*schema_, *this);
|
||||
const query::column col(query::table{type_info.name()}, type_info.primary_key_attribute()->name());
|
||||
const query::column col(std::make_shared<query::table>(type_info.name()), type_info.primary_key_attribute()->name());
|
||||
using namespace matador::query;
|
||||
auto data = eqb.build<Type>(col == utils::_);
|
||||
if (!data.is_ok()) {
|
||||
|
||||
@@ -10,25 +10,25 @@ namespace matador::query {
|
||||
|
||||
class table;
|
||||
|
||||
// ReSharper disable CppNonExplicitConvertingConstructor
|
||||
class column {
|
||||
public:
|
||||
column(const char *name, const std::string& as = ""); // NOLINT(*-explicit-constructor)
|
||||
column(std::string name, std::string as = "");
|
||||
column(sql::sql_function_t func, std::string name); // NOLINT(*-explicit-constructor)
|
||||
column(const class table &tab, std::string name, std::string as = "");
|
||||
column(std::string name, std::string as = ""); // NOLINT(*-explicit-constructor)
|
||||
column(sql::sql_function_t func, std::string name);
|
||||
// column(const class table &tab, std::string name, std::string as = "");
|
||||
column(const std::shared_ptr<table> &t, std::string name, std::string as = "");
|
||||
|
||||
[[nodiscard]] bool equals(const column &x) const;
|
||||
|
||||
column& as(std::string a);
|
||||
|
||||
[[nodiscard]] const std::string& column_name() const;
|
||||
[[nodiscard]] std::string full_name() const;
|
||||
[[nodiscard]] const std::string& alias_name() const;
|
||||
[[nodiscard]] const std::string& name() const;
|
||||
[[nodiscard]] const std::string& alias() const;
|
||||
|
||||
[[nodiscard]] bool is_function() const;
|
||||
[[nodiscard]] sql::sql_function_t function() const;
|
||||
[[nodiscard]] bool has_alias() const;
|
||||
[[nodiscard]] std::string alias() const;
|
||||
|
||||
[[nodiscard]] std::shared_ptr<class table> table() const;
|
||||
void table(const std::shared_ptr<query::table>& t);
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
|
||||
private:
|
||||
std::shared_ptr<query::table> table_;
|
||||
std::string name;
|
||||
std::string name_;
|
||||
std::string alias_;
|
||||
|
||||
sql::sql_function_t function_{sql::sql_function_t::None};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef MATADOR_QUERY_UTILS_HPP
|
||||
#define MATADOR_QUERY_UTILS_HPP
|
||||
|
||||
#include "table.hpp"
|
||||
#include "matador/sql/dialect.hpp"
|
||||
|
||||
#include <string>
|
||||
@@ -12,6 +13,7 @@ namespace matador::query {
|
||||
class column;
|
||||
|
||||
[[nodiscard]] std::string prepare_identifier(const sql::dialect& d, const column &col);
|
||||
[[nodiscard]] std::string prepare_identifier(const sql::dialect& d, const table &tab, const column &col);
|
||||
[[nodiscard]] std::string prepare_criteria(const sql::dialect& d, const column &col);
|
||||
}
|
||||
#endif //MATADOR_QUERY_UTILS_HPP
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
[[nodiscard]] const std::string& alias() const;
|
||||
[[nodiscard]] const std::vector<class column>& columns() const;
|
||||
|
||||
[[nodiscard]] class column column(const std::string &name) const;
|
||||
// [[nodiscard]] class column column(const std::string &name) const;
|
||||
|
||||
operator const std::vector<query::column>&() const;
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user