use raw pointer of table in class column (progress, needs fixes in tests)
This commit is contained in:
parent
9418f28348
commit
4a19322ef8
|
|
@ -135,8 +135,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
append_join(
|
append_join(
|
||||||
query::column{table_info_stack_.top().table, table_info_stack_.top().info.get().primary_key_attribute()->name()},
|
query::column{table_info_stack_.top().table.get(), table_info_stack_.top().info.get().primary_key_attribute()->name()},
|
||||||
query::column{next->second, join_column}
|
query::column{next->second.get(), join_column}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -172,12 +172,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
append_join(
|
append_join(
|
||||||
query::column{table_info_stack_.top().table, table_info_stack_.top().info.get().primary_key_attribute()->name()},
|
query::column{table_info_stack_.top().table.get(), table_info_stack_.top().info.get().primary_key_attribute()->name()},
|
||||||
query::column{relation->second, join_column}
|
query::column{relation->second.get(), join_column}
|
||||||
);
|
);
|
||||||
append_join(
|
append_join(
|
||||||
query::column{relation->second, inverse_join_column},
|
query::column{relation->second.get(), inverse_join_column},
|
||||||
query::column{next->second, info.primary_key_attribute()->name()}
|
query::column{next->second.get(), info.primary_key_attribute()->name()}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -214,12 +214,12 @@ public:
|
||||||
const auto join_columns = join_columns_collector_.collect<typename ContainerType::value_type::value_type>();
|
const auto join_columns = join_columns_collector_.collect<typename ContainerType::value_type::value_type>();
|
||||||
|
|
||||||
append_join(
|
append_join(
|
||||||
query::column{table_info_stack_.top().table, table_info_stack_.top().info.get().primary_key_attribute()->name()},
|
query::column{table_info_stack_.top().table.get(), table_info_stack_.top().info.get().primary_key_attribute()->name()},
|
||||||
query::column{relation->second, join_columns.inverse_join_column}
|
query::column{relation->second.get(), join_columns.inverse_join_column}
|
||||||
);
|
);
|
||||||
append_join(
|
append_join(
|
||||||
query::column{relation->second, join_columns.join_column},
|
query::column{relation->second.get(), join_columns.join_column},
|
||||||
query::column{next->second, info.primary_key_attribute()->name()}
|
query::column{next->second.get(), info.primary_key_attribute()->name()}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -271,8 +271,8 @@ void session_query_builder::on_foreign_object(const char *id, Pointer &, const u
|
||||||
table_info_stack_.pop();
|
table_info_stack_.pop();
|
||||||
|
|
||||||
append_join(
|
append_join(
|
||||||
query::column{table_info_stack_.top().table, id},
|
query::column{table_info_stack_.top().table.get(), id},
|
||||||
query::column{next->second, info->get().primary_key_attribute()->name()}
|
query::column{next->second.get(), info->get().primary_key_attribute()->name()}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
push(id);
|
push(id);
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,7 @@ public:
|
||||||
column(const char *name, const std::string& as = ""); // NOLINT(*-explicit-constructor)
|
column(const char *name, const std::string& as = ""); // NOLINT(*-explicit-constructor)
|
||||||
column(std::string name, std::string as = ""); // NOLINT(*-explicit-constructor)
|
column(std::string name, std::string as = ""); // NOLINT(*-explicit-constructor)
|
||||||
column(sql::sql_function_t func, std::string name);
|
column(sql::sql_function_t func, std::string name);
|
||||||
// column(const class table &tab, std::string name, std::string as = "");
|
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;
|
[[nodiscard]] bool equals(const column &x) const;
|
||||||
|
|
||||||
|
|
@ -36,14 +35,14 @@ public:
|
||||||
[[nodiscard]] sql::sql_function_t function() const;
|
[[nodiscard]] sql::sql_function_t function() const;
|
||||||
[[nodiscard]] bool has_alias() const;
|
[[nodiscard]] bool has_alias() const;
|
||||||
|
|
||||||
[[nodiscard]] std::shared_ptr<class table> table() const;
|
[[nodiscard]] const class table* table() const;
|
||||||
void table(const std::shared_ptr<query::table>& t);
|
void table(const query::table* t);
|
||||||
|
|
||||||
// ReSharper disable once CppNonExplicitConversionOperator
|
// ReSharper disable once CppNonExplicitConversionOperator
|
||||||
operator const std::string&() const; // NOLINT(*-explicit-constructor)
|
operator const std::string&() const; // NOLINT(*-explicit-constructor)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<query::table> table_;
|
const query::table* table_{nullptr};
|
||||||
std::string name_;
|
std::string name_;
|
||||||
std::string alias_;
|
std::string alias_;
|
||||||
utils::basic_type type_{utils::basic_type::Unknown};
|
utils::basic_type type_{utils::basic_type::Unknown};
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
namespace matador::query {
|
namespace matador::query {
|
||||||
|
|
||||||
struct join_data {
|
struct join_data {
|
||||||
std::shared_ptr<table> join_table;
|
table* join_table{nullptr};
|
||||||
std::unique_ptr<abstract_criteria> condition;
|
std::unique_ptr<abstract_criteria> condition;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ void criteria_transformer::update_criteria_column(const query::abstract_column_c
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const_cast<query::column&>(node.col()).table(it->second);
|
const_cast<query::column&>(node.col()).table(it->second.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_query_builder::on_revision(const char *id, uint64_t &/*rev*/) {
|
void session_query_builder::on_revision(const char *id, uint64_t &/*rev*/) {
|
||||||
|
|
@ -56,7 +56,7 @@ void session_query_builder::push(const std::string &column_name) {
|
||||||
if (it == processed_tables_.end()) {
|
if (it == processed_tables_.end()) {
|
||||||
throw query_builder_exception{query_build_error::UnexpectedError};
|
throw query_builder_exception{query_build_error::UnexpectedError};
|
||||||
}
|
}
|
||||||
entity_query_data_.columns.emplace_back(it->second, column_name, build_alias('c', ++column_index));
|
entity_query_data_.columns.emplace_back(it->second.get(), column_name, build_alias('c', ++column_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string session_query_builder::build_alias(const char prefix, const unsigned int count) {
|
std::string session_query_builder::build_alias(const char prefix, const unsigned int count) {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ column operator ""_col(const char *name, const size_t len) {
|
||||||
throw std::invalid_argument("Invalid column name: multiple dots found");
|
throw std::invalid_argument("Invalid column name: multiple dots found");
|
||||||
}
|
}
|
||||||
|
|
||||||
return column{std::make_shared<table>(str.substr(0, pos)), str.substr(pos + 1)};
|
return column{new table(str.substr(0, pos)), str.substr(pos + 1)};
|
||||||
}
|
}
|
||||||
|
|
||||||
column::column(const char *name, const std::string& as)
|
column::column(const char *name, const std::string& as)
|
||||||
|
|
@ -26,17 +26,15 @@ column::column(const char *name, const std::string& as)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
column::column(std::string name, std::string as)
|
column::column(std::string name, std::string as)
|
||||||
: table_(std::make_shared<query::table>())
|
: name_(std::move(name))
|
||||||
, name_(std::move(name))
|
|
||||||
, alias_(std::move(as)) {}
|
, alias_(std::move(as)) {}
|
||||||
|
|
||||||
column::column(const sql::sql_function_t func, std::string name)
|
column::column(const sql::sql_function_t func, std::string name)
|
||||||
: table_(std::make_shared<query::table>())
|
: name_(std::move(name))
|
||||||
, name_(std::move(name))
|
|
||||||
, function_(func) {}
|
, function_(func) {}
|
||||||
|
|
||||||
column::column(const std::shared_ptr<query::table>& t, std::string name, std::string as)
|
column::column(const class table* tab, std::string name, std::string as)
|
||||||
: table_(t)
|
: table_(tab)
|
||||||
, name_(std::move(name))
|
, name_(std::move(name))
|
||||||
, alias_(std::move(as)) {
|
, alias_(std::move(as)) {
|
||||||
}
|
}
|
||||||
|
|
@ -85,12 +83,12 @@ bool column::has_alias() const {
|
||||||
return !alias_.empty();
|
return !alias_.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<table> column::table() const {
|
const class table* column::table() const {
|
||||||
return table_;
|
return table_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void column::table( const std::shared_ptr<query::table>& t ) {
|
void column::table(const query::table* tab) {
|
||||||
table_ = t;
|
table_ = tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
column::operator const std::string&() const {
|
column::operator const std::string&() const {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue