44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
#include "matador/query/generator.hpp"
|
|
|
|
namespace matador::query::generator {
|
|
column_generator::column_generator(const basic_schema& repo, const table* tab, const column_generator_options options)
|
|
: repo_(std::cref(repo))
|
|
, options_(options) {
|
|
table_stack_.push(tab);
|
|
}
|
|
|
|
void column_generator::on_revision(const char* id, uint64_t&) {
|
|
push(id);
|
|
}
|
|
|
|
void column_generator::push( const std::string& column_name ) {
|
|
if (is_column_generator_option_set(options_, column_generator_options::GenerateAlias)) {
|
|
char str[4];
|
|
snprintf(str, 4, "c%02d", ++column_index);
|
|
result_.emplace_back(table_stack_.top(), column_name, str);
|
|
} else {
|
|
result_.emplace_back(table_stack_.top(), column_name);
|
|
}
|
|
}
|
|
|
|
void placeholder_generator::on_revision(const char* /*id*/, uint64_t&) {
|
|
result_.emplace_back(utils::_);
|
|
}
|
|
|
|
column_value_generator::column_value_generator(column_value_generator_options options)
|
|
: options_(options) {}
|
|
|
|
void column_value_generator::on_revision(const char* id, uint64_t& x) {
|
|
push_back(id, x);
|
|
}
|
|
|
|
std::vector<utils::placeholder> placeholders(const size_t num) {
|
|
std::vector<utils::placeholder> result;
|
|
for (size_t i = 0; i < num; ++i) {
|
|
result.emplace_back(utils::_);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|