Compare commits
No commits in common. "19de5714f4beeacd95cad9cbeb703d9b1430bdd6" and "27f6c81da2a27454a0942aa60b97fecace6c709a" have entirely different histories.
19de5714f4
...
27f6c81da2
|
|
@ -5,7 +5,6 @@
|
||||||
#include "matador/sql/entity.hpp"
|
#include "matador/sql/entity.hpp"
|
||||||
|
|
||||||
#include "matador/utils/access.hpp"
|
#include "matador/utils/access.hpp"
|
||||||
#include "matador/utils/enum_mapper.hpp"
|
|
||||||
|
|
||||||
#include "matador/sql/query_helper.hpp"
|
#include "matador/sql/query_helper.hpp"
|
||||||
|
|
||||||
|
|
@ -91,71 +90,6 @@ struct job {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const matador::utils::enum_mapper<job::job_state> job_state_enum({
|
|
||||||
{job::job_state::Pending, "Pending"},
|
|
||||||
{job::job_state::Running, "Running"},
|
|
||||||
{job::job_state::Succeeded, "Succeeded"},
|
|
||||||
{job::job_state::Failed, "Failed"},
|
|
||||||
{job::job_state::Canceled, "Canceled"}
|
|
||||||
});
|
|
||||||
|
|
||||||
static const matador::utils::enum_mapper<job::job_mode> job_mode_enum({
|
|
||||||
{job::job_mode::Foreground, "Foreground"},
|
|
||||||
{job::job_mode::Background, "Background"}
|
|
||||||
});
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct matador::sql::data_type_traits<job::job_state, void>
|
|
||||||
{
|
|
||||||
inline static data_type_t builtin_type(std::size_t size)
|
|
||||||
{ return data_type_traits<std::string>::builtin_type(size); }
|
|
||||||
|
|
||||||
static void read_value(query_result_reader &reader, const char *id, size_t index, job::job_state &value)
|
|
||||||
{
|
|
||||||
std::string enum_string;
|
|
||||||
reader.read_value(id, index, enum_string, 64);
|
|
||||||
if (const auto enum_opt = job_state_enum.to_enum(enum_string)) {
|
|
||||||
value = enum_opt.value();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static any_type create_value(const job::job_state &value)
|
|
||||||
{
|
|
||||||
return job_state_enum.to_string(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void bind_value(parameter_binder &binder, size_t index, job::job_state &value)
|
|
||||||
{
|
|
||||||
binder.bind(index, job_state_enum.to_string(value));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct matador::sql::data_type_traits<job::job_mode, void>
|
|
||||||
{
|
|
||||||
inline static data_type_t builtin_type(std::size_t size)
|
|
||||||
{ return data_type_traits<std::string>::builtin_type(size); }
|
|
||||||
|
|
||||||
static void read_value(query_result_reader &reader, const char *id, size_t index, job::job_mode &value)
|
|
||||||
{
|
|
||||||
std::string enum_string;
|
|
||||||
reader.read_value(id, index, enum_string, 64);
|
|
||||||
if (const auto enum_opt = job_mode_enum.to_enum(enum_string)) {
|
|
||||||
value = enum_opt.value();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static any_type create_value(const job::job_mode &value)
|
|
||||||
{
|
|
||||||
return job_mode_enum.to_string(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void bind_value(parameter_binder &binder, size_t index, job::job_mode &value)
|
|
||||||
{
|
|
||||||
binder.bind(index, job_mode_enum.to_string(value));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
QUERY_HELPER( authors, id, first_name, last_name, date_of_birth, year_of_birth, distinguished )
|
QUERY_HELPER( authors, id, first_name, last_name, date_of_birth, year_of_birth, distinguished )
|
||||||
|
|
||||||
QUERY_HELPER( books, id, author_id, title, published_in )
|
QUERY_HELPER( books, id, author_id, title, published_in )
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ public:
|
||||||
auto at = data_type_traits<T>::create_value(value);
|
auto at = data_type_traits<T>::create_value(value);
|
||||||
any_type_to_string_visitor value_to_string(d, query);
|
any_type_to_string_visitor value_to_string(d, query);
|
||||||
std::visit(value_to_string, at);
|
std::visit(value_to_string, at);
|
||||||
return value_to_string.result + " " + operand + " " + d.prepare_identifier(field_);
|
return "'" + value_to_string.result + "' " + operand + " " + d.prepare_identifier(field_);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -14,22 +14,13 @@ struct table
|
||||||
table(const char *name, std::string as = "") // NOLINT(*-explicit-constructor)
|
table(const char *name, std::string as = "") // NOLINT(*-explicit-constructor)
|
||||||
: name(name), alias(std::move(as)) {}
|
: name(name), alias(std::move(as)) {}
|
||||||
table(std::string name, std::string as = "") // NOLINT(*-explicit-constructor)
|
table(std::string name, std::string as = "") // NOLINT(*-explicit-constructor)
|
||||||
: name(std::move(name))
|
: name(std::move(name)), alias(std::move(as)) {}
|
||||||
, alias(std::move(as)) {}
|
|
||||||
table(std::string name, std::string as, const std::vector<column> &columns)
|
|
||||||
: name(std::move(name))
|
|
||||||
, alias(std::move(as))
|
|
||||||
, columns(columns) {}
|
|
||||||
|
|
||||||
table& as(const std::string &a) {
|
table& as(const std::string &a) {
|
||||||
alias = a;
|
alias = a;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] table as(const std::string &a) const {
|
|
||||||
return { name, a, columns };
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string alias;
|
std::string alias;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue