37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
#include "matador/orm/session_query_builder.hpp"
|
|
|
|
#include <iostream>
|
|
|
|
namespace matador::orm {
|
|
void session_query_builder::on_revision(const char *id, unsigned long long &/*rev*/) {
|
|
push(id);
|
|
}
|
|
|
|
void session_query_builder::push(const std::string &column_name) {
|
|
const auto it = processed_tables_.find(table_info_stack_.top().info.get().name());
|
|
if (it == processed_tables_.end()) {
|
|
throw query_builder_exception{query_build_error::UnexpectedError};
|
|
}
|
|
entity_query_data_.columns.emplace_back(it->second, column_name, build_alias('c', ++column_index));
|
|
}
|
|
|
|
std::string session_query_builder::build_alias(const char prefix, const unsigned int count) {
|
|
char str[4];
|
|
snprintf(str, 4, "%c%02d", prefix, count);
|
|
|
|
return str;
|
|
}
|
|
|
|
[[nodiscard]] bool session_query_builder::is_root_entity() const {
|
|
return table_info_stack_.size() == 1;
|
|
}
|
|
|
|
void session_query_builder::append_join(const sql::column &left, const sql::column &right) {
|
|
using namespace matador::query;
|
|
entity_query_data_.joins.push_back({
|
|
{right.table_},
|
|
make_condition(left == right)
|
|
});
|
|
}
|
|
}
|