handle many-to-many relations separately when process entities
This commit is contained in:
@@ -91,6 +91,7 @@ set(SQL_HEADER
|
||||
../include/matador/sql/field.hpp
|
||||
../include/matador/sql/entity_query_builder.hpp
|
||||
../include/matador/sql/table_definition.hpp
|
||||
../include/matador/sql/has_many_to_many_relation.hpp
|
||||
)
|
||||
|
||||
set(QUERY_SOURCES
|
||||
|
||||
@@ -6,7 +6,7 @@ condition<column, placeholder, std::enable_if<true>::type>::condition(const colu
|
||||
: basic_column_condition(fld, op), value(val)
|
||||
{}
|
||||
|
||||
std::string condition<column, placeholder, std::enable_if<true>::type>::evaluate(dialect &d, query_context &query) const
|
||||
std::string condition<column, placeholder, std::enable_if<true>::type>::evaluate(const dialect &d, query_context &query) const
|
||||
{
|
||||
query.bind_vars.emplace_back(field_.name);
|
||||
return d.prepare_identifier(field_) + " " + operand + " " + d.next_placeholder(query.bind_vars);
|
||||
@@ -16,7 +16,7 @@ condition<column, query_context>::condition(column col, basic_condition::operand
|
||||
: basic_column_condition(std::move(col), op), query_(q)
|
||||
{}
|
||||
|
||||
std::string condition<column, query_context>::evaluate(dialect &d, query_context &query) const
|
||||
std::string condition<column, query_context>::evaluate(const dialect &d, query_context &query) const
|
||||
{
|
||||
std::string result(d.prepare_identifier(field_) + " " + operand + " (");
|
||||
result += (")");
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ std::string dialect::prepare_identifier_string(const std::string &col) const
|
||||
|
||||
for (auto &part : parts) {
|
||||
escape_quotes_in_identifier(part);
|
||||
quote_identifier(part);
|
||||
// quote_identifier(part);
|
||||
}
|
||||
return utils::join(parts, ".");
|
||||
}
|
||||
|
||||
+13
-1
@@ -15,7 +15,10 @@ std::string schema::name() const
|
||||
|
||||
const table_info& schema::attach(const std::type_index ti, const table_info& table)
|
||||
{
|
||||
return repository_.try_emplace(ti, table).first->second;
|
||||
|
||||
auto &ref = repository_.try_emplace(ti, table).first->second;
|
||||
repository_by_name_.try_emplace(ref.name, std::ref(ref));
|
||||
return ref;
|
||||
}
|
||||
|
||||
std::optional<table_info> schema::info(std::type_index ti) const
|
||||
@@ -27,6 +30,15 @@ std::optional<table_info> schema::info(std::type_index ti) const
|
||||
return it->second;
|
||||
}
|
||||
|
||||
std::optional<table_info> schema::info(const std::string &name) const
|
||||
{
|
||||
const auto it = repository_by_name_.find(name);
|
||||
if (it == repository_by_name_.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
std::pair<std::string, std::string> schema::reference(const std::type_index &ti) const
|
||||
{
|
||||
const auto it = repository_.find(ti);
|
||||
|
||||
Reference in New Issue
Block a user