added returning to update statement and added error code implementation for query
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#ifndef MATADOR_ERROR_CODE_HPP
|
||||
#define MATADOR_ERROR_CODE_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <system_error>
|
||||
|
||||
namespace matador::query {
|
||||
enum class error_code {
|
||||
Success,
|
||||
Failure,
|
||||
InvalidQuery,
|
||||
InvalidSchema,
|
||||
InvalidTable,
|
||||
InvalidColumn,
|
||||
InvalidConstraint,
|
||||
InvalidDataType,
|
||||
InvalidValue
|
||||
};
|
||||
|
||||
class query_category_impl final : public std::error_category
|
||||
{
|
||||
public:
|
||||
[[nodiscard]] const char* name() const noexcept override;
|
||||
[[nodiscard]] std::string message(int ev) const override;
|
||||
};
|
||||
|
||||
const std::error_category& query_category();
|
||||
std::error_code make_error_code(error_code e);
|
||||
std::error_condition make_error_condition(error_code e);
|
||||
|
||||
}
|
||||
|
||||
template <>
|
||||
struct std::is_error_code_enum<matador::query::error_code> : true_type {};
|
||||
#endif //MATADOR_ERROR_CODE_HPP
|
||||
@@ -2,6 +2,7 @@
|
||||
#define QUERY_EXECUTE_WHERE_INTERMEDIATE_HPP
|
||||
|
||||
#include "matador/query/intermediates/executable_query.hpp"
|
||||
#include "matador/query/intermediates/fetchable_query.hpp"
|
||||
|
||||
namespace matador::query {
|
||||
|
||||
@@ -14,9 +15,18 @@ class query_execute_where_intermediate : public executable_query
|
||||
public:
|
||||
using executable_query::executable_query;
|
||||
|
||||
template<typename... TableColumns>
|
||||
fetchable_query returning(const TableColumns&... table_columns) {
|
||||
const std::vector<table_column> tcv { table_columns... };
|
||||
return returning(tcv);
|
||||
}
|
||||
|
||||
query_execute_limit_intermediate limit(size_t limit);
|
||||
query_execute_order_by_intermediate order_by(const table_column &col);
|
||||
query_execute_order_by_intermediate order_by(std::initializer_list<table_column> columns);
|
||||
|
||||
private:
|
||||
fetchable_query returning(const std::vector<table_column>& tables);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -2,22 +2,13 @@
|
||||
#define QUERY_INTO_INTERMEDIATE_HPP
|
||||
|
||||
#include "matador/query/intermediates/executable_query.hpp"
|
||||
#include "matador/query/intermediates/fetchable_query.hpp"
|
||||
#include "matador/query/intermediates/query_values_intermediate.hpp"
|
||||
|
||||
#include "matador/query/value_extractor.hpp"
|
||||
|
||||
#include "matador/utils/placeholder.hpp"
|
||||
|
||||
namespace matador::query {
|
||||
class table_column;
|
||||
|
||||
class query_values_intermediate : public executable_query {
|
||||
public:
|
||||
using executable_query::executable_query;
|
||||
|
||||
fetchable_query returning(const table_column &col);
|
||||
};
|
||||
|
||||
class query_into_intermediate : public query_intermediate {
|
||||
public:
|
||||
using query_intermediate::query_intermediate;
|
||||
|
||||
@@ -9,14 +9,11 @@
|
||||
|
||||
namespace matador::query {
|
||||
|
||||
class query_set_intermediate : public executable_query
|
||||
{
|
||||
class query_set_intermediate : public executable_query {
|
||||
public:
|
||||
using executable_query::executable_query;
|
||||
|
||||
query_execute_where_intermediate where(std::unique_ptr<abstract_criteria> cond) {
|
||||
return where_clause(std::move(cond));
|
||||
}
|
||||
query_execute_where_intermediate where(std::unique_ptr<abstract_criteria> cond);
|
||||
|
||||
private:
|
||||
query_execute_where_intermediate where_clause(std::unique_ptr<abstract_criteria> &&cond);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef MATADOR_QUERY_VALUES_INTERMEDIATE_H
|
||||
#define MATADOR_QUERY_VALUES_INTERMEDIATE_H
|
||||
|
||||
#include "matador/query/intermediates/executable_query.hpp"
|
||||
#include "matador/query/intermediates/fetchable_query.hpp"
|
||||
|
||||
namespace matador::query {
|
||||
class table_column;
|
||||
class query_values_intermediate : public executable_query {
|
||||
public:
|
||||
using executable_query::executable_query;
|
||||
|
||||
template<typename... TableColumns>
|
||||
fetchable_query returning(const TableColumns&... table_columns) {
|
||||
const std::vector<table_column> tcv { table_columns... };
|
||||
return returning(tcv);
|
||||
}
|
||||
|
||||
private:
|
||||
fetchable_query returning(const std::vector<table_column>& tables);
|
||||
};
|
||||
}
|
||||
|
||||
#endif //MATADOR_QUERY_VALUES_INTERMEDIATE_H
|
||||
Reference in New Issue
Block a user