fixed compilation and tests
This commit is contained in:
parent
78abf16f28
commit
19b0adf737
|
|
@ -125,7 +125,7 @@ std::string postgres_connection::generate_statement_name(const sql::query_contex
|
|||
utils::result<std::unique_ptr<sql::statement_impl>, utils::error> postgres_connection::prepare(const sql::query_context &context) {
|
||||
auto statement_name = postgres_connection::generate_statement_name(context);
|
||||
|
||||
PGresult *result = PQprepare(conn_, statement_name.c_str(), context.sql.c_str(),
|
||||
const PGresult *result = PQprepare(conn_, statement_name.c_str(), context.sql.c_str(),
|
||||
static_cast<int>(context.bind_vars.size()), nullptr);
|
||||
|
||||
if (is_result_error(result)) {
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ void attribute_generator::on_primary_key(const char *id, ValueType &x, const uti
|
|||
}
|
||||
|
||||
template<typename Type>
|
||||
void attribute_generator::on_attribute(const char *id, Type &x, const utils::field_attributes &attr) {
|
||||
void attribute_generator::on_attribute(const char *id, Type &/*x*/, const utils::field_attributes &attr) {
|
||||
columns_.emplace_back(id, utils::data_type_traits<Type>::type(attr.size()), attr, null_option_type::NOT_NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public:
|
|||
|
||||
template < typename Type >
|
||||
static std::shared_ptr<repository_node> make_node(repository& repo, const std::string& name) {
|
||||
auto node = std::make_shared<repository_node>( repo, name, typeid( Type ) );
|
||||
auto node = std::shared_ptr<repository_node>(new repository_node(repo, name, typeid(Type)));
|
||||
|
||||
primary_key_resolver resolver;
|
||||
auto pk_info = resolver.resolve<Type>();
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public:
|
|||
[[nodiscard]] bool has_alias() const;
|
||||
[[nodiscard]] std::string alias() const;
|
||||
|
||||
[[nodiscard]] std::shared_ptr<table> table() const;
|
||||
[[nodiscard]] std::shared_ptr<class table> table() const;
|
||||
void table(const std::shared_ptr<query::table>& t);
|
||||
|
||||
operator const std::string&() const;
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@ public:
|
|||
|
||||
class query_alter_table_part final : public query_part {
|
||||
public:
|
||||
explicit query_alter_table_part(table tab);
|
||||
explicit query_alter_table_part(class table tab);
|
||||
|
||||
void accept(query_part_visitor &visitor) override;
|
||||
|
||||
[[nodiscard]] const table& table() const;
|
||||
[[nodiscard]] const class table& table() const;
|
||||
|
||||
private:
|
||||
query::table table_;
|
||||
|
|
@ -68,10 +68,10 @@ private:
|
|||
|
||||
class query_add_foreign_key_reference_part final : public query_part {
|
||||
public:
|
||||
explicit query_add_foreign_key_reference_part(table tab, const std::vector<column>& columns);
|
||||
explicit query_add_foreign_key_reference_part(class table tab, const std::vector<column>& columns);
|
||||
void accept(query_part_visitor &visitor) override;
|
||||
|
||||
[[nodiscard]] const table& table() const;
|
||||
[[nodiscard]] const class table& table() const;
|
||||
[[nodiscard]] const std::vector<column>& columns() const;
|
||||
|
||||
private:
|
||||
|
|
@ -116,9 +116,9 @@ private:
|
|||
class query_from_part final : public query_part
|
||||
{
|
||||
public:
|
||||
explicit query_from_part(table t);
|
||||
explicit query_from_part(class table tab);
|
||||
|
||||
[[nodiscard]] const table& table() const;
|
||||
[[nodiscard]] const class table& table() const;
|
||||
|
||||
private:
|
||||
void accept(query_part_visitor &visitor) override;
|
||||
|
|
@ -130,9 +130,9 @@ private:
|
|||
class query_join_part final : public query_part
|
||||
{
|
||||
public:
|
||||
explicit query_join_part(table t);
|
||||
explicit query_join_part(class table tab);
|
||||
|
||||
[[nodiscard]] const table& table() const;
|
||||
[[nodiscard]] const class table& table() const;
|
||||
|
||||
private:
|
||||
void accept(query_part_visitor &visitor) override;
|
||||
|
|
@ -189,9 +189,9 @@ protected:
|
|||
class query_group_by_part final : public query_part
|
||||
{
|
||||
public:
|
||||
explicit query_group_by_part(column col);
|
||||
explicit query_group_by_part(class column col);
|
||||
|
||||
[[nodiscard]] const column& column() const;
|
||||
[[nodiscard]] const class column& column() const;
|
||||
|
||||
private:
|
||||
void accept(query_part_visitor &visitor) override;
|
||||
|
|
@ -203,9 +203,9 @@ private:
|
|||
class query_order_by_part final : public query_part
|
||||
{
|
||||
public:
|
||||
explicit query_order_by_part(column col);
|
||||
explicit query_order_by_part(class column col);
|
||||
|
||||
[[nodiscard]] const column& column() const;
|
||||
[[nodiscard]] const class column& column() const;
|
||||
|
||||
private:
|
||||
void accept(query_part_visitor &visitor) override;
|
||||
|
|
@ -272,9 +272,9 @@ private:
|
|||
class query_into_part final : public query_part
|
||||
{
|
||||
public:
|
||||
query_into_part(table t, std::vector<column> columns);
|
||||
query_into_part(class table tab, std::vector<column> columns);
|
||||
|
||||
[[nodiscard]] const table& table() const;
|
||||
[[nodiscard]] const class table& table() const;
|
||||
[[nodiscard]] const std::vector<column>& columns() const;
|
||||
|
||||
private:
|
||||
|
|
@ -304,9 +304,9 @@ private:
|
|||
class query_update_part final : public query_part
|
||||
{
|
||||
public:
|
||||
explicit query_update_part(table table);
|
||||
explicit query_update_part(class table tab);
|
||||
|
||||
[[nodiscard]] const table& table() const;
|
||||
[[nodiscard]] const class table& table() const;
|
||||
|
||||
private:
|
||||
void accept(query_part_visitor &visitor) override;
|
||||
|
|
@ -341,9 +341,9 @@ private:
|
|||
class query_delete_from_part final : public query_part
|
||||
{
|
||||
public:
|
||||
explicit query_delete_from_part(table table);
|
||||
explicit query_delete_from_part(class table tab);
|
||||
|
||||
[[nodiscard]] const table& table() const;
|
||||
[[nodiscard]] const class table& table() const;
|
||||
|
||||
private:
|
||||
void accept(query_part_visitor &visitor) override;
|
||||
|
|
@ -364,9 +364,9 @@ private:
|
|||
class query_create_table_part final : public query_part
|
||||
{
|
||||
public:
|
||||
query_create_table_part(table table, std::vector<object::attribute> columns);
|
||||
query_create_table_part(class table tab, std::vector<object::attribute> columns);
|
||||
|
||||
[[nodiscard]] const table& table() const;
|
||||
[[nodiscard]] const class table& table() const;
|
||||
[[nodiscard]] const std::vector<object::attribute>& columns() const;
|
||||
|
||||
private:
|
||||
|
|
@ -402,9 +402,9 @@ private:
|
|||
class query_drop_table_part final : public query_part
|
||||
{
|
||||
public:
|
||||
explicit query_drop_table_part(table table);
|
||||
explicit query_drop_table_part(class table tab);
|
||||
|
||||
[[nodiscard]] const table& table() const;
|
||||
[[nodiscard]] const class table& table() const;
|
||||
|
||||
private:
|
||||
void accept(query_part_visitor &visitor) override;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public:
|
|||
table(const char *name); // NOLINT(*-explicit-constructor)
|
||||
table(std::string name); // NOLINT(*-explicit-constructor)
|
||||
table(std::string name, std::string as);
|
||||
table(std::string name, std::string as, const std::vector<column> &columns);
|
||||
table(std::string name, std::string as, const std::vector<class column> &columns);
|
||||
|
||||
table& as(const std::string &a);
|
||||
|
||||
|
|
@ -28,9 +28,9 @@ public:
|
|||
|
||||
[[nodiscard]] const std::string& name() const;
|
||||
[[nodiscard]] const std::string& alias() const;
|
||||
[[nodiscard]] const std::vector<column>& columns() const;
|
||||
[[nodiscard]] const std::vector<class column>& columns() const;
|
||||
|
||||
[[nodiscard]] column column(const std::string &name) const;
|
||||
[[nodiscard]] class column column(const std::string &name) const;
|
||||
|
||||
operator const std::vector<query::column>&() const;
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -108,9 +108,9 @@ const std::vector<column>& query_select_part::columns() const
|
|||
return columns_;
|
||||
}
|
||||
|
||||
query_from_part::query_from_part(class table t)
|
||||
query_from_part::query_from_part(class table tab)
|
||||
: query_part(sql::dialect_token::From)
|
||||
, table_(std::move(t)) {}
|
||||
, table_(std::move(tab)) {}
|
||||
|
||||
const table &query_from_part::table() const
|
||||
{
|
||||
|
|
@ -122,9 +122,9 @@ void query_from_part::accept(query_part_visitor &visitor)
|
|||
visitor.visit(*this);
|
||||
}
|
||||
|
||||
query_join_part::query_join_part(class table t)
|
||||
query_join_part::query_join_part(class table tab)
|
||||
: query_part(sql::dialect_token::Join)
|
||||
, table_(std::move(t)) {}
|
||||
, table_(std::move(tab)) {}
|
||||
|
||||
const table &query_join_part::table() const
|
||||
{
|
||||
|
|
@ -252,9 +252,9 @@ void query_insert_part::accept(query_part_visitor &visitor)
|
|||
visitor.visit(*this);
|
||||
}
|
||||
|
||||
query_into_part::query_into_part(class table t, std::vector<column> columns)
|
||||
query_into_part::query_into_part(class table tab, std::vector<column> columns)
|
||||
: query_part(sql::dialect_token::Insert)
|
||||
, table_(std::move(t))
|
||||
, table_(std::move(tab))
|
||||
, columns_(std::move(columns)) {}
|
||||
|
||||
const table &query_into_part::table() const
|
||||
|
|
@ -286,9 +286,9 @@ void query_values_part::accept(query_part_visitor &visitor)
|
|||
visitor.visit(*this);
|
||||
}
|
||||
|
||||
query_update_part::query_update_part(class table table)
|
||||
query_update_part::query_update_part(class table tab)
|
||||
: query_part(sql::dialect_token::Update)
|
||||
, table_(std::move(table)) {}
|
||||
, table_(std::move(tab)) {}
|
||||
|
||||
const table& query_update_part::table() const
|
||||
{
|
||||
|
|
@ -322,9 +322,9 @@ void query_delete_part::accept(query_part_visitor &visitor)
|
|||
visitor.visit(*this);
|
||||
}
|
||||
|
||||
query_delete_from_part::query_delete_from_part(class table table)
|
||||
query_delete_from_part::query_delete_from_part(class table tab)
|
||||
: query_part(sql::dialect_token::From)
|
||||
, table_(std::move(table)) {}
|
||||
, table_(std::move(tab)) {}
|
||||
|
||||
const table &query_delete_from_part::table() const
|
||||
{
|
||||
|
|
@ -344,9 +344,9 @@ void query_create_part::accept(query_part_visitor &visitor)
|
|||
visitor.visit(*this);
|
||||
}
|
||||
|
||||
query_create_table_part::query_create_table_part(class table table, std::vector<object::attribute> columns)
|
||||
query_create_table_part::query_create_table_part(class table tab, std::vector<object::attribute> columns)
|
||||
: query_part(sql::dialect_token::Table)
|
||||
, table_(std::move(table))
|
||||
, table_(std::move(tab))
|
||||
, columns_(std::move(columns)) {}
|
||||
|
||||
const table &query_create_table_part::table() const
|
||||
|
|
@ -384,9 +384,9 @@ void query_drop_part::accept(query_part_visitor &visitor)
|
|||
visitor.visit(*this);
|
||||
}
|
||||
|
||||
query_drop_table_part::query_drop_table_part(class table table)
|
||||
query_drop_table_part::query_drop_table_part(class table tab)
|
||||
: query_part(sql::dialect_token::Table)
|
||||
, table_(std::move(table)) {}
|
||||
, table_(std::move(tab)) {}
|
||||
|
||||
const table &query_drop_table_part::table() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,19 +16,31 @@ struct airplane {
|
|||
unsigned int id{};
|
||||
std::string brand;
|
||||
std::string model;
|
||||
|
||||
template<class Operator>
|
||||
void process(Operator &op) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador::utils;
|
||||
field::primary_key(op, "id", id);
|
||||
field::attribute(op, "brand", brand, 255);
|
||||
field::attribute(op, "model", model, 255);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace matador::access {
|
||||
template<class Operator>
|
||||
void process(Operator &op, test::airplane &object) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador::utils;
|
||||
field::primary_key(op, "id", object.id);
|
||||
field::attribute(op, "brand", object.brand, 255);
|
||||
field::attribute(op, "model", object.model, 255);
|
||||
}
|
||||
|
||||
}
|
||||
// namespace matador::access {
|
||||
// template<class Operator>
|
||||
// void process(Operator &op, matador::test::airplane &object) {
|
||||
// namespace field = matador::access;
|
||||
// using namespace matador::utils;
|
||||
// field::primary_key(op, "id", object.id);
|
||||
// field::attribute(op, "brand", object.brand, 255);
|
||||
// field::attribute(op, "model", object.model, 255);
|
||||
// }
|
||||
// template<class Operator>
|
||||
// void process(Operator &op, const matador::test::airplane &object) {
|
||||
// process(op, const_cast<matador::test::airplane &>(object));
|
||||
// }
|
||||
// }
|
||||
#endif //QUERY_AIRPLANE_HPP
|
||||
|
|
|
|||
Loading…
Reference in New Issue