mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-02 19:20:42 -06:00
Merge branch 'release/0.10'
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
sqlpp11
|
||||
=======
|
||||
|
||||
A type safe template library for SQL queries and results in C++
|
||||
A type safe embedded domain specific language for SQL queries and results in C++
|
||||
|
||||
|
||||
Motivation:
|
||||
@@ -22,7 +22,7 @@ This results in several benefits, e.g.
|
||||
|
||||
The library supports both static and dynamic queries. The former offers greater benefit in terms of type and consistency checking. The latter makes it easier to construct queries on the flight.
|
||||
|
||||
Specific traits of databases (e.g. unsupported or non-standard features) are known at compile time as well. This way, the compiler can tell the developer at compile time if a query is not accepted by the database (e.g. if a feature is missing). And the library can form the query in the correct manner, for instance if the engine uses concat instead of operator|| to concatenate strings.
|
||||
sqlpp11 is vendor-neutral. Specific traits of databases (e.g. unsupported or non-standard features) are are handled by connector libraries. Connector libraries can inform the developer of missing features at compile time. They also interpret expressions specifically where needed. For example, the connector could use the operator|| or the concat method for string concatenation without the developer being required to change the statement.
|
||||
|
||||
|
||||
Your help is needed:
|
||||
@@ -64,14 +64,14 @@ for (const auto& row : db.run(select(all_of(foo)).from(foo).where(foo.hasFun or
|
||||
}
|
||||
|
||||
// selecting zero or one row, showing off with an alias:
|
||||
SQLPP_ALIAS_PROVIDER_GENERATOR(cheese);
|
||||
SQLPP_ALIAS_PROVIDER(cheese);
|
||||
if (const auto& row = db.run(select(foo.name.as(cheese)).from(foo).where(foo.id == 17)))
|
||||
{
|
||||
std::cerr << "found: " << row.cheese << std::endl;
|
||||
}
|
||||
|
||||
// selecting a single row with a single result:
|
||||
return db.run(select(count(foo.id)).from(foo)).front().count;
|
||||
return db.run(select(count(foo.id)).from(foo).where(true)).front().count;
|
||||
|
||||
Of course there are joins and subqueries, more functions, order_by, group_by etc.
|
||||
These will be documented soon.
|
||||
|
||||
@@ -57,11 +57,7 @@ namespace sqlpp
|
||||
};
|
||||
};
|
||||
|
||||
any_t(Select&& select):
|
||||
_select(std::move(select))
|
||||
{}
|
||||
|
||||
any_t(const Select& select):
|
||||
any_t(Select select):
|
||||
_select(select)
|
||||
{}
|
||||
|
||||
@@ -92,9 +88,9 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
auto any(T&& t) -> typename vendor::any_t<typename operand_t<T, is_select_t>::type>
|
||||
auto any(T t) -> typename vendor::any_t<typename operand_t<T, is_select_t>::type>
|
||||
{
|
||||
return { std::forward<T>(t) };
|
||||
return { t };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,11 +57,7 @@ namespace sqlpp
|
||||
};
|
||||
};
|
||||
|
||||
avg_t(Expr&& expr):
|
||||
_expr(std::move(expr))
|
||||
{}
|
||||
|
||||
avg_t(const Expr& expr):
|
||||
avg_t(Expr expr):
|
||||
_expr(expr)
|
||||
{}
|
||||
|
||||
@@ -98,15 +94,15 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto avg(T&& t) -> typename vendor::avg_t<vendor::noop, typename operand_t<T, is_value_t>::type>
|
||||
auto avg(T t) -> typename vendor::avg_t<vendor::noop, typename operand_t<T, is_value_t>::type>
|
||||
{
|
||||
return { std::forward<T>(t) };
|
||||
return { t };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto avg(const sqlpp::distinct_t&, T&& t) -> typename vendor::avg_t<sqlpp::distinct_t, typename operand_t<T, is_value_t>::type>
|
||||
auto avg(const sqlpp::distinct_t&, T t) -> typename vendor::avg_t<sqlpp::distinct_t, typename operand_t<T, is_value_t>::type>
|
||||
{
|
||||
return { std::forward<T>(t) };
|
||||
return { t };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,44 +46,44 @@ namespace sqlpp
|
||||
struct basic_operators
|
||||
{
|
||||
template<typename T>
|
||||
vendor::equal_t<Base, typename Constraint<T>::type> operator==(T&& t) const
|
||||
vendor::equal_t<Base, typename Constraint<T>::type> operator==(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
vendor::not_equal_t<Base, typename Constraint<T>::type> operator!=(T&& t) const
|
||||
vendor::not_equal_t<Base, typename Constraint<T>::type> operator!=(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
template<typename T>
|
||||
vendor::less_than_t<Base, typename Constraint<T>::type> operator<(T&& t) const
|
||||
vendor::less_than_t<Base, typename Constraint<T>::type> operator<(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
vendor::less_equal_t<Base, typename Constraint<T>::type> operator<=(T&& t) const
|
||||
vendor::less_equal_t<Base, typename Constraint<T>::type> operator<=(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
vendor::greater_than_t<Base, typename Constraint<T>::type> operator>(T&& t) const
|
||||
vendor::greater_than_t<Base, typename Constraint<T>::type> operator>(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
vendor::greater_equal_t<Base, typename Constraint<T>::type> operator>=(T&& t) const
|
||||
vendor::greater_equal_t<Base, typename Constraint<T>::type> operator>=(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
vendor::is_null_t<true, Base> is_null() const
|
||||
@@ -112,21 +112,21 @@ namespace sqlpp
|
||||
|
||||
// Hint: use value_list wrapper for containers...
|
||||
template<typename... T>
|
||||
vendor::in_t<true, Base, typename Constraint<T>::type...> in(T&&... t) const
|
||||
vendor::in_t<true, Base, typename Constraint<T>::type...> in(T... t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used with in()");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)}... };
|
||||
return { *static_cast<const Base*>(this), {t}... };
|
||||
}
|
||||
|
||||
template<typename... T>
|
||||
vendor::in_t<false, Base, typename Constraint<T>::type...> not_in(T&&... t) const
|
||||
vendor::in_t<false, Base, typename Constraint<T>::type...> not_in(T... t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot with be used with not_in()");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)}... };
|
||||
return { *static_cast<const Base*>(this), {t}... };
|
||||
}
|
||||
|
||||
template<typename alias_provider>
|
||||
expression_alias_t<Base, typename std::decay<alias_provider>::type> as(alias_provider&&)
|
||||
expression_alias_t<Base, alias_provider> as(const alias_provider&)
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot have a name");
|
||||
return { *static_cast<const Base*>(this) };
|
||||
|
||||
@@ -168,17 +168,17 @@ namespace sqlpp
|
||||
struct operators: public basic_operators<Base, _operand_t>
|
||||
{
|
||||
template<typename T>
|
||||
vendor::logical_and_t<Base, typename _operand_t<T>::type> operator and(T&& t) const
|
||||
vendor::logical_and_t<Base, typename _operand_t<T>::type> operator and(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
vendor::logical_or_t<Base, typename _operand_t<T>::type> operator or(T&& t) const
|
||||
vendor::logical_or_t<Base, typename _operand_t<T>::type> operator or(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
vendor::logical_not_t<Base> operator not() const
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <sqlpp11/vendor/assignment.h>
|
||||
#include <sqlpp11/vendor/expression.h>
|
||||
#include <sqlpp11/vendor/interpreter.h>
|
||||
#include <sqlpp11/detail/wrong.h>
|
||||
#include <sqlpp11/vendor/wrong.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
@@ -68,7 +68,7 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename alias_provider>
|
||||
expression_alias_t<column_t, typename std::decay<alias_provider>::type> as(alias_provider&&) const
|
||||
expression_alias_t<column_t, alias_provider> as(const alias_provider&) const
|
||||
{
|
||||
return { *this };
|
||||
}
|
||||
|
||||
@@ -57,11 +57,7 @@ namespace sqlpp
|
||||
};
|
||||
};
|
||||
|
||||
count_t(Expr&& expr):
|
||||
_expr(std::move(expr))
|
||||
{}
|
||||
|
||||
count_t(const Expr& expr):
|
||||
count_t(const Expr expr):
|
||||
_expr(expr)
|
||||
{}
|
||||
|
||||
@@ -98,15 +94,15 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto count(T&& t) -> typename vendor::count_t<vendor::noop, typename operand_t<T, is_value_t>::type>
|
||||
auto count(T t) -> typename vendor::count_t<vendor::noop, typename operand_t<T, is_value_t>::type>
|
||||
{
|
||||
return { std::forward<T>(t) };
|
||||
return { t };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto count(const sqlpp::distinct_t&, T&& t) -> typename vendor::count_t<sqlpp::distinct_t, typename operand_t<T, is_value_t>::type>
|
||||
auto count(const sqlpp::distinct_t&, T t) -> typename vendor::count_t<sqlpp::distinct_t, typename operand_t<T, is_value_t>::type>
|
||||
{
|
||||
return { std::forward<T>(t) };
|
||||
return { t };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,40 +32,31 @@ namespace sqlpp
|
||||
namespace detail
|
||||
{
|
||||
template<typename Expr>
|
||||
auto make_single_expression_tuple(Expr&& expr)
|
||||
-> typename std::enable_if<is_named_expression_t<typename std::decay<Expr>::type>::value, decltype(std::make_tuple(expr))>::type
|
||||
auto make_single_expression_tuple(Expr expr)
|
||||
-> typename std::enable_if<is_named_expression_t<Expr>::value, decltype(std::make_tuple(expr))>::type
|
||||
{
|
||||
return std::make_tuple(std::forward<Expr>(expr));
|
||||
return std::make_tuple(expr);
|
||||
};
|
||||
|
||||
template<typename Expr>
|
||||
auto make_single_expression_tuple(Expr&& expr)
|
||||
-> typename std::enable_if<is_select_flag_t<typename std::decay<Expr>::type>::value, std::tuple<>>::type
|
||||
auto make_single_expression_tuple(Expr expr)
|
||||
-> typename std::enable_if<is_select_flag_t<Expr>::value, std::tuple<>>::type
|
||||
{
|
||||
return {};
|
||||
};
|
||||
|
||||
/*
|
||||
template<typename Tab>
|
||||
auto make_single_expression_tuple(Tab&& tab)
|
||||
-> typename std::enable_if<is_table_t<typename std::decay<Tab>::type>::value, typename std::decay<Tab>::type::_all_of_t>::type
|
||||
{
|
||||
return {};
|
||||
};
|
||||
*/
|
||||
|
||||
template<typename... Expr>
|
||||
auto make_single_expression_tuple(std::tuple<Expr...>&& t)
|
||||
auto make_single_expression_tuple(std::tuple<Expr...> t)
|
||||
-> std::tuple<Expr...>
|
||||
{
|
||||
return t;
|
||||
};
|
||||
|
||||
template<typename... Expr>
|
||||
auto make_expression_tuple(Expr&&... expr)
|
||||
-> decltype(std::tuple_cat(make_single_expression_tuple(std::forward<Expr>(expr))...))
|
||||
auto make_expression_tuple(Expr... expr)
|
||||
-> decltype(std::tuple_cat(make_single_expression_tuple(expr)...))
|
||||
{
|
||||
return std::tuple_cat(make_single_expression_tuple(std::forward<Expr>(expr))...);
|
||||
return std::tuple_cat(make_single_expression_tuple(expr)...);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -33,36 +33,36 @@ namespace sqlpp
|
||||
{
|
||||
// accept select flags
|
||||
template<typename Expr>
|
||||
auto make_single_flag_tuple(Expr&& expr) -> typename std::enable_if<is_select_flag_t<typename std::decay<Expr>::type>::value, decltype(std::make_tuple(expr))>::type
|
||||
auto make_single_flag_tuple(Expr expr) -> typename std::enable_if<is_select_flag_t<Expr>::value, decltype(std::make_tuple(expr))>::type
|
||||
{
|
||||
return std::make_tuple(std::forward<Expr>(expr));
|
||||
return std::make_tuple(expr);
|
||||
};
|
||||
|
||||
// ignore named expressions
|
||||
template<typename Expr>
|
||||
auto make_single_flag_tuple(Expr&& expr) -> typename std::enable_if<is_named_expression_t<typename std::decay<Expr>::type>::value, std::tuple<>>::type
|
||||
auto make_single_flag_tuple(Expr expr) -> typename std::enable_if<is_named_expression_t<Expr>::value, std::tuple<>>::type
|
||||
{
|
||||
return {};
|
||||
};
|
||||
|
||||
// ignore tables
|
||||
template<typename Tab>
|
||||
auto make_single_flag_tuple(Tab&& tab) -> typename std::enable_if<is_table_t<typename std::decay<Tab>::type>::value, std::tuple<>>::type
|
||||
auto make_single_flag_tuple(Tab tab) -> typename std::enable_if<is_table_t<Tab>::value, std::tuple<>>::type
|
||||
{
|
||||
return {};
|
||||
};
|
||||
|
||||
// ignore tuples of expressions
|
||||
template<typename... Expr>
|
||||
auto make_single_flag_tuple(std::tuple<Expr...>&& t) -> std::tuple<>
|
||||
auto make_single_flag_tuple(std::tuple<Expr...> t) -> std::tuple<>
|
||||
{
|
||||
return {};
|
||||
};
|
||||
|
||||
template<typename... Expr>
|
||||
auto make_flag_tuple(Expr&&... expr) -> decltype(std::tuple_cat(make_single_flag_tuple(std::forward<Expr>(expr))...))
|
||||
auto make_flag_tuple(Expr... expr) -> decltype(std::tuple_cat(make_single_flag_tuple(expr)...))
|
||||
{
|
||||
return std::tuple_cat(make_single_flag_tuple(std::forward<Expr>(expr))...);
|
||||
return std::tuple_cat(make_single_flag_tuple(expr)...);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#define SQLPP_DETAIL_SET_H
|
||||
|
||||
#include <type_traits>
|
||||
#include <sqlpp11/detail/wrong.h>
|
||||
#include <sqlpp11/vendor/wrong.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
@@ -76,7 +76,7 @@ namespace sqlpp
|
||||
template<typename T>
|
||||
struct is_superset_of
|
||||
{
|
||||
static_assert(wrong<T>::value, "invalid argument for is_superset_of");
|
||||
static_assert(::sqlpp::vendor::wrong_t<T>::value, "invalid argument for is_superset_of");
|
||||
};
|
||||
|
||||
template<typename... T>
|
||||
@@ -86,7 +86,7 @@ namespace sqlpp
|
||||
template<typename T>
|
||||
struct join
|
||||
{
|
||||
static_assert(wrong<T>::value, "invalid argument for set::join");
|
||||
static_assert(::sqlpp::vendor::wrong_t<T>::value, "invalid argument for set::join");
|
||||
};
|
||||
|
||||
template<typename... T>
|
||||
@@ -96,7 +96,7 @@ namespace sqlpp
|
||||
template<typename T>
|
||||
struct is_disjunct_from
|
||||
{
|
||||
static_assert(wrong<T>::value, "invalid argument for is_disjunct_from");
|
||||
static_assert(::sqlpp::vendor::wrong_t<T>::value, "invalid argument for is_disjunct_from");
|
||||
};
|
||||
|
||||
template<typename... T>
|
||||
@@ -106,7 +106,7 @@ namespace sqlpp
|
||||
template<typename T>
|
||||
struct is_subset_of
|
||||
{
|
||||
static_assert(wrong<T>::value, "invalid argument for is_subset_of");
|
||||
static_assert(::sqlpp::vendor::wrong_t<T>::value, "invalid argument for is_subset_of");
|
||||
};
|
||||
|
||||
template<typename... T>
|
||||
@@ -116,7 +116,7 @@ namespace sqlpp
|
||||
template<typename T>
|
||||
struct equals
|
||||
{
|
||||
static_assert(wrong<T>::value, "invalid argument for equals");
|
||||
static_assert(::sqlpp::vendor::wrong_t<T>::value, "invalid argument for equals");
|
||||
};
|
||||
|
||||
template<typename... T>
|
||||
|
||||
@@ -55,11 +55,7 @@ namespace sqlpp
|
||||
};
|
||||
};
|
||||
|
||||
exists_t(Select&& select):
|
||||
_select(std::move(select))
|
||||
{}
|
||||
|
||||
exists_t(const Select& select):
|
||||
exists_t(Select select):
|
||||
_select(select)
|
||||
{}
|
||||
|
||||
@@ -92,9 +88,9 @@ namespace sqlpp
|
||||
|
||||
|
||||
template<typename T>
|
||||
auto exists(T&& t) -> typename vendor::exists_t<typename operand_t<T, is_select_t>::type>
|
||||
auto exists(T t) -> typename vendor::exists_t<typename operand_t<T, is_select_t>::type>
|
||||
{
|
||||
return { std::forward<T>(t) };
|
||||
return { t };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -170,31 +170,31 @@ namespace sqlpp
|
||||
struct operators: public basic_operators<Base, _operand_t>
|
||||
{
|
||||
template<typename T>
|
||||
vendor::plus_t<Base, floating_point, typename _operand_t<T>::type> operator +(T&& t) const
|
||||
vendor::plus_t<Base, floating_point, typename _operand_t<T>::type> operator +(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
vendor::minus_t<Base, floating_point, typename _operand_t<T>::type> operator -(T&& t) const
|
||||
vendor::minus_t<Base, floating_point, typename _operand_t<T>::type> operator -(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
vendor::multiplies_t<Base, floating_point, typename _operand_t<T>::type> operator *(T&& t) const
|
||||
vendor::multiplies_t<Base, floating_point, typename _operand_t<T>::type> operator *(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
vendor::divides_t<Base, typename _operand_t<T>::type> operator /(T&& t) const
|
||||
vendor::divides_t<Base, typename _operand_t<T>::type> operator /(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
vendor::unary_plus_t<floating_point, Base> operator +() const
|
||||
@@ -210,27 +210,27 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator +=(T&& t) const -> decltype(std::declval<Base>() = std::declval<Base>() + std::forward<T>(t))
|
||||
auto operator +=(T t) const -> decltype(std::declval<Base>() = std::declval<Base>() + t)
|
||||
{
|
||||
return *static_cast<const Base*>(this) = operator +(std::forward<T>(t));
|
||||
return *static_cast<const Base*>(this) = operator +(t);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator -=(T&& t) const -> decltype(std::declval<Base>() = std::declval<Base>() - std::forward<T>(t))
|
||||
auto operator -=(T t) const -> decltype(std::declval<Base>() = std::declval<Base>() - t)
|
||||
{
|
||||
return *static_cast<const Base*>(this) = operator -(std::forward<T>(t));
|
||||
return *static_cast<const Base*>(this) = operator -(t);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator /=(T&& t) const -> decltype(std::declval<Base>() = std::declval<Base>() / std::forward<T>(t))
|
||||
auto operator /=(T t) const -> decltype(std::declval<Base>() = std::declval<Base>() / t)
|
||||
{
|
||||
return *static_cast<const Base*>(this) = operator /(std::forward<T>(t));
|
||||
return *static_cast<const Base*>(this) = operator /(t);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator *=(T&& t) const -> decltype(std::declval<Base>() = std::declval<Base>() * std::forward<T>(t))
|
||||
auto operator *=(T t) const -> decltype(std::declval<Base>() = std::declval<Base>() * t)
|
||||
{
|
||||
return *static_cast<const Base*>(this) = operator *(std::forward<T>(t));
|
||||
return *static_cast<const Base*>(this) = operator *(t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -45,10 +45,10 @@
|
||||
namespace sqlpp
|
||||
{
|
||||
template<typename T>
|
||||
auto value(T&& t) -> typename operand_t<T, is_value_t>::type
|
||||
auto value(T t) -> typename operand_t<T, is_value_t>::type
|
||||
{
|
||||
static_assert(not is_value_t<typename std::decay<T>::type>::value, "value() is to be called with non-sql-type like int, or string");
|
||||
return { std::forward<T>(t) };
|
||||
static_assert(not is_value_t<T>::value, "value() is to be called with non-sql-type like int, or string");
|
||||
return { t };
|
||||
}
|
||||
|
||||
template<typename ValueType> // Csaba Csoma suggests: unsafe_sql instead of verbatim
|
||||
@@ -56,8 +56,7 @@ namespace sqlpp
|
||||
{
|
||||
using _value_type = ValueType;
|
||||
|
||||
verbatim_t(const std::string& verbatim): _verbatim(verbatim) {}
|
||||
verbatim_t(std::string&& verbatim): _verbatim(std::forward<std::string>(verbatim)) {}
|
||||
verbatim_t(std::string verbatim): _verbatim(verbatim) {}
|
||||
verbatim_t(const verbatim_t&) = default;
|
||||
verbatim_t(verbatim_t&&) = default;
|
||||
verbatim_t& operator=(const verbatim_t&) = default;
|
||||
@@ -83,13 +82,13 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename ValueType, typename StringType>
|
||||
auto verbatim(StringType&& s) -> verbatim_t<ValueType>
|
||||
auto verbatim(StringType s) -> verbatim_t<ValueType>
|
||||
{
|
||||
return { std::forward<StringType>(s) };
|
||||
return { s };
|
||||
}
|
||||
|
||||
template<typename Expression, typename Context>
|
||||
auto flatten(const Expression& exp, const Context& context) -> verbatim_t<typename std::decay<Expression>::type::_value_type::_base_value_type>
|
||||
auto flatten(const Expression& exp, const Context& context) -> verbatim_t<typename Expression::_value_type::_base_value_type>
|
||||
{
|
||||
static_assert(not make_parameter_list_t<Expression>::type::size::value, "parameters not supported in flattened expressions");
|
||||
context.clear();
|
||||
@@ -141,16 +140,16 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename Container>
|
||||
auto value_list(Container&& c) -> value_list_t<typename std::decay<Container>::type>
|
||||
auto value_list(Container c) -> value_list_t<Container>
|
||||
{
|
||||
static_assert(not is_value_t<typename std::decay<Container>::type::value_type>::value, "value_list() is to be called with a container of non-sql-type like std::vector<int>, or std::list(string)");
|
||||
return { std::forward<Container>(c) };
|
||||
static_assert(not is_value_t<typename Container::value_type>::value, "value_list() is to be called with a container of non-sql-type like std::vector<int>, or std::list(string)");
|
||||
return { c };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr const char* get_sql_name(const T&)
|
||||
{
|
||||
return std::decay<T>::type::_name_t::_get_name();
|
||||
return T::type::_name_t::_get_name();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -76,40 +76,40 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename... Assignment>
|
||||
auto set(Assignment&&... assignment)
|
||||
-> set_insert_list_t<vendor::insert_list_t<void, typename std::decay<Assignment>::type...>>
|
||||
auto set(Assignment... assignment)
|
||||
-> set_insert_list_t<vendor::insert_list_t<void, Assignment...>>
|
||||
{
|
||||
static_assert(std::is_same<InsertList, vendor::noop>::value, "cannot call set() after set() or default_values()");
|
||||
static_assert(vendor::is_noop<ColumnList>::value, "cannot call set() after columns()");
|
||||
// FIXME: Need to check if all required columns are set
|
||||
return {
|
||||
_table,
|
||||
vendor::insert_list_t<void, typename std::decay<Assignment>::type...>{std::forward<Assignment>(assignment)...},
|
||||
vendor::insert_list_t<void, Assignment...>{assignment...},
|
||||
_column_list,
|
||||
_value_list,
|
||||
};
|
||||
}
|
||||
|
||||
template<typename... Assignment>
|
||||
auto dynamic_set(Assignment&&... assignment)
|
||||
-> set_insert_list_t<vendor::insert_list_t<Database, typename std::decay<Assignment>::type...>>
|
||||
auto dynamic_set(Assignment... assignment)
|
||||
-> set_insert_list_t<vendor::insert_list_t<Database, Assignment...>>
|
||||
{
|
||||
static_assert(std::is_same<InsertList, vendor::noop>::value, "cannot call set() after set() or default_values()");
|
||||
static_assert(vendor::is_noop<ColumnList>::value, "cannot call set() after columns()");
|
||||
return {
|
||||
_table,
|
||||
vendor::insert_list_t<Database, typename std::decay<Assignment>::type...>{std::forward<Assignment>(assignment)...},
|
||||
vendor::insert_list_t<Database, Assignment...>{assignment...},
|
||||
_column_list,
|
||||
_value_list,
|
||||
};
|
||||
}
|
||||
|
||||
template<typename Assignment>
|
||||
insert_t add_set(Assignment&& assignment)
|
||||
insert_t add_set(Assignment assignment)
|
||||
{
|
||||
static_assert(is_dynamic_t<InsertList>::value, "cannot call add_set() in a non-dynamic set");
|
||||
|
||||
_insert_list.add(std::forward<Assignment>(assignment));
|
||||
_insert_list.add(assignment);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename Db>
|
||||
std::size_t run(Db& db) const
|
||||
std::size_t _run(Db& db) const
|
||||
{
|
||||
static_assert(not (vendor::is_noop<InsertList>::value and vendor::is_noop<ColumnList>::value) , "calling set() or default_values()");
|
||||
static_assert(_get_static_no_of_parameters() == 0, "cannot run insert directly with parameters, use prepare instead");
|
||||
@@ -157,8 +157,8 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename Db>
|
||||
auto prepare(Db& db) const
|
||||
-> prepared_insert_t<typename std::decay<Db>::type, insert_t>
|
||||
auto _prepare(Db& db) const
|
||||
-> prepared_insert_t<Db, insert_t>
|
||||
{
|
||||
constexpr bool calledSet = not vendor::is_noop<InsertList>::value;
|
||||
constexpr bool requireSet = Table::_required_insert_columns::size::value > 0;
|
||||
@@ -205,15 +205,15 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename Table>
|
||||
insert_t<void, typename std::decay<Table>::type> insert_into(Table&& table)
|
||||
insert_t<void, Table> insert_into(Table table)
|
||||
{
|
||||
return {std::forward<Table>(table)};
|
||||
return {table};
|
||||
}
|
||||
|
||||
template<typename Database, typename Table>
|
||||
insert_t<typename std::decay<Database>::type, typename std::decay<Table>::type> dynamic_insert_into(Database&& db, Table&& table)
|
||||
insert_t<Database, Table> dynamic_insert_into(const Database& db, Table table)
|
||||
{
|
||||
return {std::forward<Table>(table)};
|
||||
return {table};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -170,38 +170,38 @@ namespace sqlpp
|
||||
struct operators: public basic_operators<Base, _operand_t>
|
||||
{
|
||||
template<typename T>
|
||||
vendor::plus_t<Base, vendor::value_type_t<T>, typename _operand_t<T>::type> operator +(T&& t) const
|
||||
vendor::plus_t<Base, vendor::value_type_t<T>, typename _operand_t<T>::type> operator +(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
vendor::minus_t<Base, vendor::value_type_t<T>, typename _operand_t<T>::type> operator -(T&& t) const
|
||||
vendor::minus_t<Base, vendor::value_type_t<T>, typename _operand_t<T>::type> operator -(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
vendor::multiplies_t<Base, vendor::value_type_t<T>, typename _operand_t<T>::type> operator *(T&& t) const
|
||||
vendor::multiplies_t<Base, vendor::value_type_t<T>, typename _operand_t<T>::type> operator *(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
vendor::divides_t<Base, typename _operand_t<T>::type> operator /(T&& t) const
|
||||
vendor::divides_t<Base, typename _operand_t<T>::type> operator /(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
vendor::modulus_t<Base, typename _operand_t<T>::type> operator %(T&& t) const
|
||||
vendor::modulus_t<Base, typename _operand_t<T>::type> operator %(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
vendor::unary_plus_t<integral, Base> operator +() const
|
||||
@@ -217,27 +217,27 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator +=(T&& t) const -> decltype(std::declval<Base>() = std::declval<Base>() + std::forward<T>(t))
|
||||
auto operator +=(T t) const -> decltype(std::declval<Base>() = std::declval<Base>() + t)
|
||||
{
|
||||
return *static_cast<const Base*>(this) = operator +(std::forward<T>(t));
|
||||
return *static_cast<const Base*>(this) = operator +(t);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator -=(T&& t) const -> decltype(std::declval<Base>() = std::declval<Base>() - std::forward<T>(t))
|
||||
auto operator -=(T t) const -> decltype(std::declval<Base>() = std::declval<Base>() - t)
|
||||
{
|
||||
return *static_cast<const Base*>(this) = operator -(std::forward<T>(t));
|
||||
return *static_cast<const Base*>(this) = operator -(t);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator /=(T&& t) const -> decltype(std::declval<Base>() = std::declval<Base>() / std::forward<T>(t))
|
||||
auto operator /=(T t) const -> decltype(std::declval<Base>() = std::declval<Base>() / t)
|
||||
{
|
||||
return *static_cast<const Base*>(this) = operator /(std::forward<T>(t));
|
||||
return *static_cast<const Base*>(this) = operator /(t);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto operator *=(T&& t) const -> decltype(std::declval<Base>() = std::declval<Base>() * std::forward<T>(t))
|
||||
auto operator *=(T t) const -> decltype(std::declval<Base>() = std::declval<Base>() * t)
|
||||
{
|
||||
return *static_cast<const Base*>(this) = operator *(std::forward<T>(t));
|
||||
return *static_cast<const Base*>(this) = operator *(t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace sqlpp
|
||||
{
|
||||
template<typename T, typename Context>
|
||||
auto interpret(const T& t, Context& context)
|
||||
-> decltype(vendor::interpreter_t<typename std::decay<Context>::type, typename std::decay<T>::type>::_(t, context))
|
||||
-> decltype(vendor::interpreter_t<Context, T>::_(t, context))
|
||||
{
|
||||
return vendor::interpreter_t<typename std::decay<Context>::type, typename std::decay<T>::type>::_(t, context);
|
||||
return vendor::interpreter_t<Context, T>::_(t, context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,49 +92,49 @@ namespace sqlpp
|
||||
using set_on_t = join_t<JoinType, Lhs, Rhs, OnT>;
|
||||
|
||||
template<typename... Expr>
|
||||
auto on(Expr&&... expr)
|
||||
-> set_on_t<on_t<void, typename std::decay<Expr>::type...>>
|
||||
auto on(Expr... expr)
|
||||
-> set_on_t<on_t<void, Expr...>>
|
||||
{
|
||||
static_assert(vendor::is_noop<On>::value, "cannot call on() twice for a single join()");
|
||||
return { _lhs,
|
||||
_rhs,
|
||||
{std::tuple<typename std::decay<Expr>::type...>{std::forward<Expr>(expr)...}}
|
||||
{std::tuple<Expr...>{expr...}}
|
||||
};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
join_t<inner_join_t, join_t, typename std::decay<T>::type> join(T&& t)
|
||||
join_t<inner_join_t, join_t, T> join(T t)
|
||||
{
|
||||
static_assert(not vendor::is_noop<On>::value, "join type requires on()");
|
||||
return { *this, std::forward<T>(t) };
|
||||
return { *this, t };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
join_t<inner_join_t, join_t, typename std::decay<T>::type> inner_join(T&& t)
|
||||
join_t<inner_join_t, join_t, T> inner_join(T t)
|
||||
{
|
||||
static_assert(not vendor::is_noop<On>::value, "join type requires on()");
|
||||
return { *this, std::forward<T>(t) };
|
||||
return { *this, t };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
join_t<outer_join_t, join_t, typename std::decay<T>::type> outer_join(T&& t)
|
||||
join_t<outer_join_t, join_t, T> outer_join(T t)
|
||||
{
|
||||
static_assert(not vendor::is_noop<On>::value, "join type requires on()");
|
||||
return { *this, std::forward<T>(t) };
|
||||
return { *this, t };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
join_t<left_outer_join_t, join_t, typename std::decay<T>::type> left_outer_join(T&& t)
|
||||
join_t<left_outer_join_t, join_t, T> left_outer_join(T t)
|
||||
{
|
||||
static_assert(not vendor::is_noop<On>::value, "join type requires on()");
|
||||
return { *this, std::forward<T>(t) };
|
||||
return { *this, t };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
join_t<right_outer_join_t, join_t, typename std::decay<T>::type> right_outer_join(T&& t)
|
||||
join_t<right_outer_join_t, join_t, T> right_outer_join(T t)
|
||||
{
|
||||
static_assert(not vendor::is_noop<On>::value, "join type requires on()");
|
||||
return { *this, std::forward<T>(t) };
|
||||
return { *this, t };
|
||||
}
|
||||
|
||||
Lhs _lhs;
|
||||
|
||||
@@ -56,11 +56,7 @@ namespace sqlpp
|
||||
};
|
||||
};
|
||||
|
||||
max_t(Expr&& expr):
|
||||
_expr(std::move(expr))
|
||||
{}
|
||||
|
||||
max_t(const Expr& expr):
|
||||
max_t(Expr expr):
|
||||
_expr(expr)
|
||||
{}
|
||||
|
||||
@@ -92,9 +88,9 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto max(T&& t) -> typename vendor::max_t<typename operand_t<T, is_value_t>::type>
|
||||
auto max(T t) -> typename vendor::max_t<typename operand_t<T, is_value_t>::type>
|
||||
{
|
||||
return { std::forward<T>(t) };
|
||||
return { t };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,11 +56,7 @@ namespace sqlpp
|
||||
};
|
||||
};
|
||||
|
||||
min_t(Expr&& expr):
|
||||
_expr(std::move(expr))
|
||||
{}
|
||||
|
||||
min_t(const Expr& expr):
|
||||
min_t(Expr expr):
|
||||
_expr(expr)
|
||||
{}
|
||||
|
||||
@@ -92,9 +88,9 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto min(T&& t) -> typename vendor::min_t<typename operand_t<T, is_value_t>::type>
|
||||
auto min(T t) -> typename vendor::min_t<typename operand_t<T, is_value_t>::type>
|
||||
{
|
||||
return { std::forward<T>(t) };
|
||||
return { t };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace sqlpp
|
||||
template<typename AliasProvider, typename T>
|
||||
struct multi_column_t
|
||||
{
|
||||
static_assert(detail::wrong<T>::value, "invalid argument for multicolumn_t");
|
||||
static_assert(vendor::wrong_t<T>::value, "invalid argument for multicolumn_t");
|
||||
};
|
||||
|
||||
template<typename AliasProvider, typename... NamedExpr>
|
||||
@@ -74,13 +74,13 @@ namespace sqlpp
|
||||
{
|
||||
template<typename AliasProvider, typename... Expr>
|
||||
using make_multi_column_t =
|
||||
multi_column_t<typename std::decay<AliasProvider>::type, decltype(make_expression_tuple(std::declval<Expr>()...))>;
|
||||
multi_column_t<AliasProvider, decltype(make_expression_tuple(std::declval<Expr>()...))>;
|
||||
}
|
||||
|
||||
template<typename AliasProvider, typename... NamedExpr>
|
||||
detail::make_multi_column_t<AliasProvider, NamedExpr...> multi_column(AliasProvider&& aliasProvider, NamedExpr&&... namedExpr)
|
||||
detail::make_multi_column_t<AliasProvider, NamedExpr...> multi_column(const AliasProvider& aliasProvider, NamedExpr... namedExpr)
|
||||
{
|
||||
return { detail::make_expression_tuple(std::forward<NamedExpr>(namedExpr)...)};
|
||||
return { detail::make_expression_tuple(namedExpr...)};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,10 +45,10 @@ namespace sqlpp
|
||||
static_assert(_valid_expressions::size::value == sizeof...(Expr), "at least one argument is not an expression in on()");
|
||||
|
||||
template<typename E>
|
||||
void add(E&& expr)
|
||||
void add(E expr)
|
||||
{
|
||||
static_assert(is_expression_t<typename std::decay<E>::type>::value, "invalid expression argument in add_on()");
|
||||
_dynamic_expressions.emplace_back(std::forward<E>(expr));
|
||||
static_assert(is_expression_t<E>::value, "invalid expression argument in add_on()");
|
||||
_dynamic_expressions.emplace_back(expr);
|
||||
}
|
||||
|
||||
std::tuple<Expr...> _expressions;
|
||||
|
||||
@@ -65,8 +65,8 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename NamedExpr>
|
||||
auto parameter(NamedExpr&& namedExpr)
|
||||
-> parameter_t<typename std::decay<NamedExpr>::type::_value_type, typename std::decay<NamedExpr>::type>
|
||||
auto parameter(NamedExpr namedExpr)
|
||||
-> parameter_t<typename NamedExpr::_value_type, NamedExpr>
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#ifndef SQLPP_PARAMETER_LIST_H
|
||||
#define SQLPP_PARAMETER_LIST_H
|
||||
|
||||
#include <sqlpp11/detail/wrong.h>
|
||||
#include <sqlpp11/vendor/wrong.h>
|
||||
#include <tuple>
|
||||
|
||||
namespace sqlpp
|
||||
@@ -35,7 +35,7 @@ namespace sqlpp
|
||||
template<typename T>
|
||||
struct parameter_list_t
|
||||
{
|
||||
static_assert(detail::wrong<T>::value, "Template parameter for parameter_list_t has to be a tuple");
|
||||
static_assert(vendor::wrong_t<T>::value, "Template parameter for parameter_list_t has to be a tuple");
|
||||
};
|
||||
|
||||
template<typename... Parameter>
|
||||
@@ -102,7 +102,7 @@ namespace sqlpp
|
||||
template<typename Exp>
|
||||
struct make_parameter_list_t
|
||||
{
|
||||
using type = parameter_list_t<typename detail::get_parameter_tuple<typename std::decay<Exp>::type>::type>;
|
||||
using type = parameter_list_t<typename detail::get_parameter_tuple<Exp>::type>;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace sqlpp
|
||||
using _parameter_list_t = typename Insert::_parameter_list_t;
|
||||
using _prepared_statement_t = typename Db::_prepared_statement_t;
|
||||
|
||||
auto run(Db& db) const
|
||||
auto _run(Db& db) const
|
||||
-> size_t
|
||||
{
|
||||
return db.run_prepared_insert(*this);
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace sqlpp
|
||||
using _parameter_list_t = typename Remove::_parameter_list_t;
|
||||
using _prepared_statement_t = typename Db::_prepared_statement_t;
|
||||
|
||||
auto run(Db& db) const
|
||||
auto _run(Db& db) const
|
||||
-> size_t
|
||||
{
|
||||
return db.run_prepared_insert(*this);
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace sqlpp
|
||||
using _dynamic_names_t = typename Select::_dynamic_names_t;
|
||||
using _prepared_statement_t = typename Db::_prepared_statement_t;
|
||||
|
||||
auto run(Db& db) const
|
||||
auto _run(Db& db) const
|
||||
-> result_t<decltype(db.run_prepared_select(*this)), _result_row_t>
|
||||
{
|
||||
return {db.run_prepared_select(*this), _dynamic_names};
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace sqlpp
|
||||
using _parameter_list_t = typename Update::_parameter_list_t;
|
||||
using _prepared_statement_t = typename Db::_prepared_statement_t;
|
||||
|
||||
auto run(Db& db) const
|
||||
auto _run(Db& db) const
|
||||
-> size_t
|
||||
{
|
||||
return db.run_prepared_insert(*this);
|
||||
|
||||
@@ -65,70 +65,70 @@ namespace sqlpp
|
||||
using _parameter_list_t = typename make_parameter_list_t<remove_t>::type;
|
||||
|
||||
template<typename... Tab>
|
||||
auto using_(Tab&&... tab)
|
||||
-> set_using_t<vendor::using_t<void, typename std::decay<Tab>::type...>>
|
||||
auto using_(Tab... tab)
|
||||
-> set_using_t<vendor::using_t<void, Tab...>>
|
||||
{
|
||||
static_assert(vendor::is_noop<Using>::value, "cannot call using() twice");
|
||||
static_assert(vendor::is_noop<Where>::value, "cannot call using() after where()");
|
||||
return {
|
||||
_table,
|
||||
{std::tuple<typename std::decay<Tab>::type...>{std::forward<Tab>(tab)...}},
|
||||
{std::tuple<Tab...>{tab...}},
|
||||
_where
|
||||
};
|
||||
}
|
||||
|
||||
template<typename... Tab>
|
||||
auto dynamic_using_(Tab&&... tab)
|
||||
-> set_using_t<vendor::using_t<Database, typename std::decay<Tab>::type...>>
|
||||
auto dynamic_using_(Tab... tab)
|
||||
-> set_using_t<vendor::using_t<Database, Tab...>>
|
||||
{
|
||||
static_assert(vendor::is_noop<Using>::value, "cannot call using() twice");
|
||||
static_assert(vendor::is_noop<Where>::value, "cannot call using() after where()");
|
||||
return {
|
||||
_table,
|
||||
{std::tuple<typename std::decay<Tab>::type...>{std::forward<Tab>(tab)...}},
|
||||
{std::tuple<Tab...>{tab...}},
|
||||
_where
|
||||
};
|
||||
}
|
||||
|
||||
template<typename Tab>
|
||||
remove_t& add_using_(Tab&& table)
|
||||
remove_t& add_using_(Tab table)
|
||||
{
|
||||
static_assert(is_dynamic_t<Using>::value, "cannot call add_using() in a non-dynamic using");
|
||||
_using.add(std::forward<Tab>(table));
|
||||
_using.add(table);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename... Expr>
|
||||
auto where(Expr&&... expr)
|
||||
-> set_where_t<vendor::where_t<void, typename std::decay<Expr>::type...>>
|
||||
auto where(Expr... expr)
|
||||
-> set_where_t<vendor::where_t<void, Expr...>>
|
||||
{
|
||||
static_assert(vendor::is_noop<Where>::value, "cannot call where() twice");
|
||||
return {
|
||||
_table,
|
||||
_using,
|
||||
{std::tuple<typename std::decay<Expr>::type...>{std::forward<Expr>(expr)...}},
|
||||
{std::tuple<Expr...>{expr...}},
|
||||
};
|
||||
}
|
||||
|
||||
template<typename... Expr>
|
||||
auto dynamic_where(Expr&&... expr)
|
||||
-> set_where_t<vendor::where_t<Database, typename std::decay<Expr>::type...>>
|
||||
auto dynamic_where(Expr... expr)
|
||||
-> set_where_t<vendor::where_t<Database, Expr...>>
|
||||
{
|
||||
static_assert(vendor::is_noop<Where>::value, "cannot call where() twice");
|
||||
return {
|
||||
_table,
|
||||
_using,
|
||||
{std::tuple<typename std::decay<Expr>::type...>{std::forward<Expr>(expr)...}},
|
||||
{std::tuple<Expr...>{expr...}},
|
||||
};
|
||||
}
|
||||
|
||||
template<typename Expr>
|
||||
remove_t& add_where(Expr&& expr)
|
||||
remove_t& add_where(Expr expr)
|
||||
{
|
||||
static_assert(is_dynamic_t<Where>::value, "cannot call add_where() in a non-dynamic where");
|
||||
|
||||
_where.add(std::forward<Expr>(expr));
|
||||
_where.add(expr);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename Db>
|
||||
std::size_t run(Db& db) const
|
||||
std::size_t _run(Db& db) const
|
||||
{
|
||||
static_assert(_get_static_no_of_parameters() == 0, "cannot run remove directly with parameters, use prepare instead");
|
||||
static_assert(is_where_t<Where>::value, "cannot run update without having a where condition, use .where(true) to remove all rows");
|
||||
@@ -152,8 +152,8 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename Db>
|
||||
auto prepare(Db& db) const
|
||||
-> prepared_remove_t<typename std::decay<Db>::type, remove_t>
|
||||
auto _prepare(Db& db) const
|
||||
-> prepared_remove_t<Db, remove_t>
|
||||
{
|
||||
return {{}, db.prepare_remove(*this)};
|
||||
}
|
||||
@@ -182,15 +182,15 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename Table>
|
||||
constexpr remove_t<void, typename std::decay<Table>::type> remove_from(Table&& table)
|
||||
constexpr remove_t<void, Table> remove_from(Table table)
|
||||
{
|
||||
return {std::forward<Table>(table)};
|
||||
return {table};
|
||||
}
|
||||
|
||||
template<typename Db, typename Table>
|
||||
constexpr remove_t<typename std::decay<Db>::type, typename std::decay<Table>::type> dynamic_remove_from(Db&& db, Table&& table)
|
||||
constexpr remove_t<Db, Table> dynamic_remove_from(const Db&, Table table)
|
||||
{
|
||||
return {std::forward<Table>(table)};
|
||||
return {table};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,8 +27,7 @@
|
||||
#ifndef SQLPP_RESULT_H
|
||||
#define SQLPP_RESULT_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
// FIXME: include for move?
|
||||
namespace sqlpp
|
||||
{
|
||||
template<typename DbResult, typename ResultRow>
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
#include <sqlpp11/vendor/offset.h>
|
||||
#include <sqlpp11/vendor/expression.h>
|
||||
#include <sqlpp11/vendor/interpreter.h>
|
||||
#include <sqlpp11/vendor/wrong.h>
|
||||
|
||||
#include <sqlpp11/detail/wrong.h>
|
||||
#include <sqlpp11/detail/make_flag_tuple.h>
|
||||
#include <sqlpp11/detail/make_expression_tuple.h>
|
||||
|
||||
@@ -150,13 +150,13 @@ namespace sqlpp
|
||||
|
||||
// select functions
|
||||
template<typename... Flag>
|
||||
auto flags(Flag&&... flag)
|
||||
-> set_flag_list_t<vendor::select_flag_list_t<void, std::tuple<typename std::decay<Flag>::type...>>>
|
||||
auto flags(Flag... flag)
|
||||
-> set_flag_list_t<vendor::select_flag_list_t<void, std::tuple<Flag...>>>
|
||||
{
|
||||
static_assert(not FlagList::size::value, "cannot call dynamic_flags() after specifying them the first time");
|
||||
static_assert(not ColumnList::size::value, "cannot call columns() after specifying them the first time");
|
||||
return {
|
||||
{std::tuple<typename std::decay<Flag>::type...>{std::forward<Flag>(flag)...}},
|
||||
{std::tuple<Flag...>{flag...}},
|
||||
_columns,
|
||||
_from,
|
||||
_where,
|
||||
@@ -169,14 +169,14 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename... Flag>
|
||||
auto dynamic_flags(Flag&&... flag)
|
||||
-> set_flag_list_t<vendor::select_flag_list_t<Database, std::tuple<typename std::decay<Flag>::type...>>>
|
||||
auto dynamic_flags(Flag... flag)
|
||||
-> set_flag_list_t<vendor::select_flag_list_t<Database, std::tuple<Flag...>>>
|
||||
{
|
||||
static_assert(not std::is_same<Database, void>::value, "cannot call dynamic_flags() in a non-dynamic select");
|
||||
static_assert(not FlagList::size::value, "cannot call dynamic_flags() after specifying them the first time");
|
||||
static_assert(not ColumnList::size::value, "cannot call columns() after specifying them the first time");
|
||||
return {
|
||||
{std::tuple<typename std::decay<Flag>::type...>{std::forward<Flag>(flag)...}},
|
||||
{std::tuple<Flag...>{flag...}},
|
||||
_columns,
|
||||
_from,
|
||||
_where,
|
||||
@@ -189,23 +189,23 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename Flag>
|
||||
select_t& add_flag(Flag&& flag)
|
||||
select_t& add_flag(Flag flag)
|
||||
{
|
||||
static_assert(is_dynamic_t<FlagList>::value, "cannot call add_flag() in a non-dynamic column list");
|
||||
|
||||
_flags.add(std::forward<Flag>(flag));
|
||||
_flags.add(flag);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename... Column>
|
||||
auto columns(Column&&... column)
|
||||
-> set_column_list_t<vendor::select_column_list_t<void, std::tuple<typename std::decay<Column>::type...>>>
|
||||
auto columns(Column... column)
|
||||
-> set_column_list_t<vendor::select_column_list_t<void, std::tuple<Column...>>>
|
||||
{
|
||||
static_assert(not ColumnList::size::value, "cannot call columns() after specifying them the first time");
|
||||
return {
|
||||
_flags,
|
||||
{std::tuple<typename std::decay<Column>::type...>{std::forward<Column>(column)...}},
|
||||
{std::tuple<Column...>{column...}},
|
||||
_from,
|
||||
_where,
|
||||
_group_by,
|
||||
@@ -217,14 +217,14 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename... Column>
|
||||
auto dynamic_columns(Column&&... column)
|
||||
-> set_column_list_t<vendor::select_column_list_t<Database, std::tuple<typename std::decay<Column>::type...>>>
|
||||
auto dynamic_columns(Column... column)
|
||||
-> set_column_list_t<vendor::select_column_list_t<Database, std::tuple<Column...>>>
|
||||
{
|
||||
static_assert(not std::is_same<Database, void>::value, "cannot call dynamic_columns() in a non-dynamic select");
|
||||
static_assert(not ColumnList::size::value, "cannot call dynamic_columns() after specifying them the first time");
|
||||
return {
|
||||
_flags,
|
||||
{std::tuple<typename std::decay<Column>::type...>{std::forward<Column>(column)...}},
|
||||
{std::tuple<Column...>{column...}},
|
||||
_from,
|
||||
_where,
|
||||
_group_by,
|
||||
@@ -236,25 +236,25 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename NamedExpr>
|
||||
select_t& add_column(NamedExpr&& namedExpr)
|
||||
select_t& add_column(NamedExpr namedExpr)
|
||||
{
|
||||
static_assert(is_dynamic_t<ColumnList>::value, "cannot call add_column() in a non-dynamic column list");
|
||||
|
||||
_columns.add(std::forward<NamedExpr>(namedExpr));
|
||||
_columns.add(namedExpr);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename... Table>
|
||||
auto from(Table&&... table)
|
||||
-> set_from_t<vendor::from_t<void, typename std::decay<Table>::type...>>
|
||||
auto from(Table... table)
|
||||
-> set_from_t<vendor::from_t<void, Table...>>
|
||||
{
|
||||
static_assert(not vendor::is_noop<ColumnList>::value, "cannot call from() without having selected anything");
|
||||
static_assert(vendor::is_noop<From>::value, "cannot call from() twice for a single select");
|
||||
return {
|
||||
_flags,
|
||||
_columns,
|
||||
{std::tuple<typename std::decay<Table>::type...>{std::forward<Table>(table)...}},
|
||||
{std::tuple<Table...>{table...}},
|
||||
_where,
|
||||
_group_by,
|
||||
_having,
|
||||
@@ -265,8 +265,8 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename... Table>
|
||||
auto dynamic_from(Table&&... table)
|
||||
-> set_from_t<vendor::from_t<Database, typename std::decay<Table>::type...>>
|
||||
auto dynamic_from(Table... table)
|
||||
-> set_from_t<vendor::from_t<Database, Table...>>
|
||||
{
|
||||
static_assert(not std::is_same<Database, void>::value, "cannot call dynamic_from() in a non-dynamic select");
|
||||
static_assert(not vendor::is_noop<ColumnList>::value, "cannot call from() without having selected anything");
|
||||
@@ -274,7 +274,7 @@ namespace sqlpp
|
||||
return {
|
||||
_flags,
|
||||
_columns,
|
||||
{std::tuple<typename std::decay<Table>::type...>{std::forward<Table>(table)...}},
|
||||
{std::tuple<Table...>{table...}},
|
||||
_where,
|
||||
_group_by,
|
||||
_having,
|
||||
@@ -285,19 +285,19 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename Table>
|
||||
select_t& add_from(Table&& table)
|
||||
select_t& add_from(Table table)
|
||||
{
|
||||
static_assert(not vendor::is_noop<ColumnList>::value, "cannot call add_from() without having selected anything");
|
||||
static_assert(is_dynamic_t<From>::value, "cannot call add_from() in a non-dynamic from");
|
||||
|
||||
_from.add(std::forward<Table>(table));
|
||||
_from.add(table);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename... Expr>
|
||||
auto where(Expr&&... expr)
|
||||
-> set_where_t<vendor::where_t<void, typename std::decay<Expr>::type...>>
|
||||
auto where(Expr... expr)
|
||||
-> set_where_t<vendor::where_t<void, Expr...>>
|
||||
{
|
||||
static_assert(not vendor::is_noop<From>::value, "cannot call where() without a from()");
|
||||
static_assert(vendor::is_noop<Where>::value, "cannot call where() or dynamic_where() twice for a single select");
|
||||
@@ -305,7 +305,7 @@ namespace sqlpp
|
||||
_flags,
|
||||
_columns,
|
||||
_from,
|
||||
{std::tuple<typename std::decay<Expr>::type...>{std::forward<Expr>(expr)...}},
|
||||
{std::tuple<Expr...>{expr...}},
|
||||
_group_by,
|
||||
_having,
|
||||
_order_by,
|
||||
@@ -315,8 +315,8 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename... Expr>
|
||||
auto dynamic_where(Expr&&... expr)
|
||||
-> set_where_t<vendor::where_t<Database, typename std::decay<Expr>::type...>>
|
||||
auto dynamic_where(Expr... expr)
|
||||
-> set_where_t<vendor::where_t<Database, Expr...>>
|
||||
{
|
||||
static_assert(not vendor::is_noop<From>::value, "cannot call dynamic_where() without a from()");
|
||||
static_assert(vendor::is_noop<Where>::value, "cannot call where() or dynamic_where() twice for a single select");
|
||||
@@ -324,7 +324,7 @@ namespace sqlpp
|
||||
_flags,
|
||||
_columns,
|
||||
_from,
|
||||
{std::tuple<typename std::decay<Expr>::type...>{std::forward<Expr>(expr)...}},
|
||||
{std::tuple<Expr...>{expr...}},
|
||||
_group_by,
|
||||
_having,
|
||||
_order_by,
|
||||
@@ -334,18 +334,18 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename Expr>
|
||||
select_t& add_where(Expr&& expr)
|
||||
select_t& add_where(Expr expr)
|
||||
{
|
||||
static_assert(is_dynamic_t<Where>::value, "cannot call add_where() with a non-dynamic where");
|
||||
|
||||
_where.add(std::forward<Expr>(expr));
|
||||
_where.add(expr);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename... Col>
|
||||
auto group_by(Col&&... column)
|
||||
-> set_group_by_t<vendor::group_by_t<void, typename std::decay<Col>::type...>>
|
||||
auto group_by(Col... column)
|
||||
-> set_group_by_t<vendor::group_by_t<void, Col...>>
|
||||
{
|
||||
static_assert(not vendor::is_noop<From>::value, "cannot call group_by() without a from()");
|
||||
static_assert(vendor::is_noop<GroupBy>::value, "cannot call group_by() twice for a single select");
|
||||
@@ -354,7 +354,7 @@ namespace sqlpp
|
||||
_columns,
|
||||
_from,
|
||||
_where,
|
||||
{std::tuple<typename std::decay<Col>::type...>{std::forward<Col>(column)...}},
|
||||
{std::tuple<Col...>{column...}},
|
||||
_having,
|
||||
_order_by,
|
||||
_limit,
|
||||
@@ -363,8 +363,8 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename... Col>
|
||||
auto dynamic_group_by(Col&&... column)
|
||||
-> set_group_by_t<vendor::group_by_t<Database, typename std::decay<Col>::type...>>
|
||||
auto dynamic_group_by(Col... column)
|
||||
-> set_group_by_t<vendor::group_by_t<Database, Col...>>
|
||||
{
|
||||
static_assert(not vendor::is_noop<From>::value, "cannot call group_by() without a from()");
|
||||
static_assert(vendor::is_noop<GroupBy>::value, "cannot call group_by() twice for a single select");
|
||||
@@ -373,7 +373,7 @@ namespace sqlpp
|
||||
_columns,
|
||||
_from,
|
||||
_where,
|
||||
{std::tuple<typename std::decay<Col>::type...>{std::forward<Col>(column)...}},
|
||||
{std::tuple<Col...>{column...}},
|
||||
_having,
|
||||
_order_by,
|
||||
_limit,
|
||||
@@ -382,18 +382,18 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename Expr>
|
||||
select_t& add_group_by(Expr&& expr)
|
||||
select_t& add_group_by(Expr expr)
|
||||
{
|
||||
static_assert(is_dynamic_t<GroupBy>::value, "cannot call add_group_by() in a non-dynamic group_by");
|
||||
|
||||
_group_by.add(std::forward<Expr>(expr));
|
||||
_group_by.add(expr);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename... Expr>
|
||||
auto having(Expr&&... expr)
|
||||
-> set_having_t<vendor::having_t<void, typename std::decay<Expr>::type...>>
|
||||
auto having(Expr... expr)
|
||||
-> set_having_t<vendor::having_t<void, Expr...>>
|
||||
{
|
||||
static_assert(not vendor::is_noop<GroupBy>::value, "cannot call having() without a group_by");
|
||||
static_assert(vendor::is_noop<Having>::value, "cannot call having() twice for a single select");
|
||||
@@ -403,7 +403,7 @@ namespace sqlpp
|
||||
_from,
|
||||
_where,
|
||||
_group_by,
|
||||
{std::tuple<typename std::decay<Expr>::type...>{std::forward<Expr>(expr)...}},
|
||||
{std::tuple<Expr...>{expr...}},
|
||||
_order_by,
|
||||
_limit,
|
||||
_offset,
|
||||
@@ -411,8 +411,8 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename... Expr>
|
||||
auto dynamic_having(Expr&&... expr)
|
||||
-> set_having_t<vendor::having_t<Database, typename std::decay<Expr>::type...>>
|
||||
auto dynamic_having(Expr... expr)
|
||||
-> set_having_t<vendor::having_t<Database, Expr...>>
|
||||
{
|
||||
static_assert(not vendor::is_noop<GroupBy>::value, "cannot call having() without a group_by");
|
||||
static_assert(vendor::is_noop<Having>::value, "cannot call having() twice for a single select");
|
||||
@@ -422,7 +422,7 @@ namespace sqlpp
|
||||
_from,
|
||||
_where,
|
||||
_group_by,
|
||||
{std::tuple<typename std::decay<Expr>::type...>{std::forward<Expr>(expr)...}},
|
||||
{std::tuple<Expr...>{expr...}},
|
||||
_order_by,
|
||||
_limit,
|
||||
_offset,
|
||||
@@ -430,18 +430,18 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename Expr>
|
||||
select_t& add_having(Expr&& expr)
|
||||
select_t& add_having(Expr expr)
|
||||
{
|
||||
static_assert(is_dynamic_t<Having>::value, "cannot call add_having() in a non-dynamic having");
|
||||
|
||||
_having.add(std::forward<Expr>(expr));
|
||||
_having.add(expr);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename... OrderExpr>
|
||||
auto order_by(OrderExpr&&... expr)
|
||||
-> set_order_by_t<vendor::order_by_t<void, typename std::decay<OrderExpr>::type...>>
|
||||
auto order_by(OrderExpr... expr)
|
||||
-> set_order_by_t<vendor::order_by_t<void, OrderExpr...>>
|
||||
{
|
||||
static_assert(not vendor::is_noop<From>::value, "cannot call order_by() without a from()");
|
||||
static_assert(vendor::is_noop<OrderBy>::value, "cannot call order_by() twice for a single select");
|
||||
@@ -452,15 +452,15 @@ namespace sqlpp
|
||||
_where,
|
||||
_group_by,
|
||||
_having,
|
||||
{std::tuple<typename std::decay<OrderExpr>::type...>{std::forward<OrderExpr>(expr)...}},
|
||||
{std::tuple<OrderExpr...>{expr...}},
|
||||
_limit,
|
||||
_offset,
|
||||
};
|
||||
}
|
||||
|
||||
template<typename... OrderExpr>
|
||||
auto dynamic_order_by(OrderExpr&&... expr)
|
||||
-> set_order_by_t<vendor::order_by_t<Database, typename std::decay<OrderExpr>::type...>>
|
||||
auto dynamic_order_by(OrderExpr... expr)
|
||||
-> set_order_by_t<vendor::order_by_t<Database, OrderExpr...>>
|
||||
{
|
||||
static_assert(not vendor::is_noop<From>::value, "cannot call order_by() without a from()");
|
||||
static_assert(vendor::is_noop<OrderBy>::value, "cannot call order_by() twice for a single select");
|
||||
@@ -471,25 +471,25 @@ namespace sqlpp
|
||||
_where,
|
||||
_group_by,
|
||||
_having,
|
||||
{std::tuple<typename std::decay<OrderExpr>::type...>{std::forward<OrderExpr>(expr)...}},
|
||||
{std::tuple<OrderExpr...>{expr...}},
|
||||
_limit,
|
||||
_offset,
|
||||
};
|
||||
}
|
||||
|
||||
template<typename Expr>
|
||||
select_t& add_order_by(Expr&& expr)
|
||||
select_t& add_order_by(Expr expr)
|
||||
{
|
||||
static_assert(is_dynamic_t<OrderBy>::value, "cannot call add_order_by() in a non-dynamic order_by");
|
||||
|
||||
_order_by.add(std::forward<Expr>(expr));
|
||||
_order_by.add(expr);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Expr>
|
||||
auto limit(Expr limit)
|
||||
-> set_limit_t<vendor::limit_t<typename vendor::wrap_operand<typename std::decay<Expr>::type>::type>>
|
||||
-> set_limit_t<vendor::limit_t<typename vendor::wrap_operand<Expr>::type>>
|
||||
{
|
||||
static_assert(not vendor::is_noop<From>::value, "cannot call limit() without a from()");
|
||||
static_assert(vendor::is_noop<Limit>::value, "cannot call limit() twice for a single select");
|
||||
@@ -535,7 +535,7 @@ namespace sqlpp
|
||||
|
||||
template<typename Expr>
|
||||
auto offset(Expr offset)
|
||||
-> set_offset_t<vendor::offset_t<typename vendor::wrap_operand<typename std::decay<Expr>::type>::type>>
|
||||
-> set_offset_t<vendor::offset_t<typename vendor::wrap_operand<Expr>::type>>
|
||||
{
|
||||
static_assert(not vendor::is_noop<Limit>::value, "cannot call offset() without a limit");
|
||||
static_assert(vendor::is_noop<Offset>::value, "cannot call offset() twice for a single select");
|
||||
@@ -615,7 +615,7 @@ namespace sqlpp
|
||||
|
||||
// Execute
|
||||
template<typename Db>
|
||||
auto run(Db& db) const
|
||||
auto _run(Db& db) const
|
||||
-> result_t<decltype(db.select(*this)), _result_row_t>
|
||||
{
|
||||
static_assert(not vendor::is_noop<ColumnList>::value, "cannot run select without having selected anything");
|
||||
@@ -630,8 +630,8 @@ namespace sqlpp
|
||||
|
||||
// Prepare
|
||||
template<typename Db>
|
||||
auto prepare(Db& db) const
|
||||
-> prepared_select_t<typename std::decay<Db>::type, select_t>
|
||||
auto _prepare(Db& db) const
|
||||
-> prepared_select_t<Db, select_t>
|
||||
{
|
||||
static_assert(not vendor::is_noop<ColumnList>::value, "cannot run select without having selected anything");
|
||||
static_assert(is_from_t<From>::value, "cannot run select without a from()");
|
||||
@@ -731,23 +731,23 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename... NamedExpr>
|
||||
auto select(NamedExpr&&... namedExpr)
|
||||
auto select(NamedExpr... namedExpr)
|
||||
-> select_t<void, detail::make_select_flag_list_t<void, NamedExpr...>, detail::make_select_column_list_t<void, NamedExpr...>>
|
||||
{
|
||||
return {
|
||||
{ detail::make_flag_tuple(std::forward<NamedExpr>(namedExpr)...) },
|
||||
{ detail::make_expression_tuple(std::forward<NamedExpr>(namedExpr)...) },
|
||||
{ detail::make_flag_tuple(namedExpr...) },
|
||||
{ detail::make_expression_tuple(namedExpr...) },
|
||||
{}, {}, {}, {}, {}, {}, {}
|
||||
};
|
||||
}
|
||||
|
||||
template<typename Db, typename... NamedExpr>
|
||||
auto dynamic_select(const Db& db, NamedExpr&&... namedExpr)
|
||||
-> select_t<typename std::decay<Db>::type, detail::make_select_flag_list_t<typename std::decay<Db>::type, NamedExpr...>, detail::make_select_column_list_t<typename std::decay<Db>::type, NamedExpr...>>
|
||||
auto dynamic_select(const Db& db, NamedExpr... namedExpr)
|
||||
-> select_t<Db, detail::make_select_flag_list_t<Db, NamedExpr...>, detail::make_select_column_list_t<Db, NamedExpr...>>
|
||||
{
|
||||
return {
|
||||
{ detail::make_flag_tuple(std::forward<NamedExpr>(namedExpr)...) },
|
||||
{ detail::make_expression_tuple(std::forward<NamedExpr>(namedExpr)...) },
|
||||
{ detail::make_flag_tuple(namedExpr...) },
|
||||
{ detail::make_expression_tuple(namedExpr...) },
|
||||
{}, {}, {}, {}, {}, {}, {}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -57,11 +57,7 @@ namespace sqlpp
|
||||
};
|
||||
};
|
||||
|
||||
some_t(Select&& select):
|
||||
_select(std::move(select))
|
||||
{}
|
||||
|
||||
some_t(const Select& select):
|
||||
some_t(Select select):
|
||||
_select(select)
|
||||
{}
|
||||
|
||||
@@ -93,9 +89,9 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto some(T&& t) -> typename vendor::some_t<typename operand_t<T, is_select_t>::type>
|
||||
auto some(T t) -> typename vendor::some_t<typename operand_t<T, is_select_t>::type>
|
||||
{
|
||||
return { std::forward<T>(t) };
|
||||
return { t };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,11 +57,7 @@ namespace sqlpp
|
||||
};
|
||||
};
|
||||
|
||||
sum_t(Expr&& expr):
|
||||
_expr(std::move(expr))
|
||||
{}
|
||||
|
||||
sum_t(const Expr& expr):
|
||||
sum_t(Expr expr):
|
||||
_expr(expr)
|
||||
{}
|
||||
|
||||
@@ -98,15 +94,15 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto sum(T&& t) -> typename vendor::sum_t<vendor::noop, typename operand_t<T, is_value_t>::type>
|
||||
auto sum(T t) -> typename vendor::sum_t<vendor::noop, typename operand_t<T, is_value_t>::type>
|
||||
{
|
||||
return { std::forward<T>(t) };
|
||||
return { t };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto sum(const sqlpp::distinct_t&, T&& t) -> typename vendor::sum_t<sqlpp::distinct_t, typename operand_t<T, is_value_t>::type>
|
||||
auto sum(const sqlpp::distinct_t&, T t) -> typename vendor::sum_t<sqlpp::distinct_t, typename operand_t<T, is_value_t>::type>
|
||||
{
|
||||
return { std::forward<T>(t) };
|
||||
return { t };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,38 +47,38 @@ namespace sqlpp
|
||||
using _required_insert_columns = typename detail::make_set_if<require_insert_t, column_t<Table, ColumnSpec>...>::type;
|
||||
using _all_of_t = std::tuple<column_t<Table, ColumnSpec>...>;
|
||||
template<typename AliasProvider>
|
||||
using _alias_t = table_alias_t<typename std::decay<AliasProvider>::type, Table, ColumnSpec...>;
|
||||
using _alias_t = table_alias_t<AliasProvider, Table, ColumnSpec...>;
|
||||
|
||||
using _is_table = std::true_type;
|
||||
|
||||
template<typename T>
|
||||
join_t<inner_join_t, Table, typename std::decay<T>::type> join(T&& t)
|
||||
join_t<inner_join_t, Table, T> join(T t)
|
||||
{
|
||||
return { *static_cast<const Table*>(this), std::forward<T>(t) };
|
||||
return { *static_cast<const Table*>(this), t };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
join_t<inner_join_t, Table, typename std::decay<T>::type> inner_join(T&& t)
|
||||
join_t<inner_join_t, Table, T> inner_join(T t)
|
||||
{
|
||||
return { *static_cast<const Table*>(this), std::forward<T>(t) };
|
||||
return { *static_cast<const Table*>(this), t };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
join_t<outer_join_t, Table, typename std::decay<T>::type> outer_join(T&& t)
|
||||
join_t<outer_join_t, Table, T> outer_join(T t)
|
||||
{
|
||||
return { *static_cast<const Table*>(this), std::forward<T>(t) };
|
||||
return { *static_cast<const Table*>(this), t };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
join_t<left_outer_join_t, Table, typename std::decay<T>::type> left_outer_join(T&& t)
|
||||
join_t<left_outer_join_t, Table, T> left_outer_join(T t)
|
||||
{
|
||||
return { *static_cast<const Table*>(this), std::forward<T>(t) };
|
||||
return { *static_cast<const Table*>(this), t };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
join_t<right_outer_join_t, Table, typename std::decay<T>::type> right_outer_join(T&& t)
|
||||
join_t<right_outer_join_t, Table, T> right_outer_join(T t)
|
||||
{
|
||||
return { *static_cast<const Table*>(this), std::forward<T>(t) };
|
||||
return { *static_cast<const Table*>(this), t };
|
||||
}
|
||||
|
||||
template<typename AliasProvider>
|
||||
@@ -94,7 +94,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template<typename Table>
|
||||
auto all_of(Table&& t) -> typename std::decay<Table>::type::_all_of_t
|
||||
auto all_of(Table t) -> typename Table::_all_of_t
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -173,17 +173,17 @@ namespace sqlpp
|
||||
struct operators: public basic_operators<Base, _operand_t>
|
||||
{
|
||||
template<typename T>
|
||||
vendor::concat_t<Base, typename _operand_t<T>::type> operator+(T&& t) const
|
||||
vendor::concat_t<Base, typename _operand_t<T>::type> operator+(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
vendor::like_t<Base, typename _operand_t<T>::type> like(T&& t) const
|
||||
vendor::like_t<Base, typename _operand_t<T>::type> like(T t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
|
||||
return { *static_cast<const Base*>(this), {t} };
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template<typename Db>
|
||||
transaction_t<typename std::decay<Db>::type> start_transaction(Db& db, bool report_unfinished_transaction = report_auto_rollback)
|
||||
transaction_t<Db> start_transaction(Db& db, bool report_unfinished_transaction = report_auto_rollback)
|
||||
{
|
||||
return { db, report_unfinished_transaction };
|
||||
};
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace sqlpp
|
||||
|
||||
static void _(const T& t, Context& context)
|
||||
{
|
||||
static_assert(detail::wrong<T>::value, "tvin() must not be used with anything but =, ==, != and !");
|
||||
static_assert(vendor::wrong_t<T>::value, "tvin() must not be used with anything but =, ==, != and !");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace sqlpp
|
||||
template<typename T, template<typename> class IsCorrectType>
|
||||
struct operand_t
|
||||
{
|
||||
using type = typename vendor::wrap_operand<typename std::decay<T>::type>::type;
|
||||
using type = typename vendor::wrap_operand<T>::type;
|
||||
static_assert(not is_alias_t<type>::value, "expression operand must not be an alias");
|
||||
static_assert(is_expression_t<type>::value, "expression required");
|
||||
static_assert(IsCorrectType<type>::value, "invalid operand type");
|
||||
|
||||
@@ -65,71 +65,71 @@ namespace sqlpp
|
||||
using _parameter_list_t = typename make_parameter_list_t<update_t>::type;
|
||||
|
||||
template<typename... Assignment>
|
||||
auto set(Assignment&&... assignment)
|
||||
-> set_assignments_t<vendor::update_list_t<void, typename std::decay<Assignment>::type...>>
|
||||
auto set(Assignment... assignment)
|
||||
-> set_assignments_t<vendor::update_list_t<void, Assignment...>>
|
||||
{
|
||||
static_assert(vendor::is_noop<Assignments>::value, "cannot call set() twice");
|
||||
return {
|
||||
_table,
|
||||
{std::tuple<typename std::decay<Assignment>::type...>{std::forward<Assignment>(assignment)...}},
|
||||
{std::tuple<Assignment...>{assignment...}},
|
||||
_where,
|
||||
};
|
||||
}
|
||||
|
||||
template<typename... Assignment>
|
||||
auto dynamic_set(Assignment&&... assignment)
|
||||
-> set_assignments_t<vendor::update_list_t<Database, typename std::decay<Assignment>::type...>>
|
||||
auto dynamic_set(Assignment... assignment)
|
||||
-> set_assignments_t<vendor::update_list_t<Database, Assignment...>>
|
||||
{
|
||||
static_assert(vendor::is_noop<Assignments>::value, "cannot call set() twice");
|
||||
return {
|
||||
_table,
|
||||
{std::tuple<typename std::decay<Assignment>::type...>{std::forward<Assignment>(assignment)...}},
|
||||
{std::tuple<Assignment...>{assignment...}},
|
||||
_where,
|
||||
};
|
||||
}
|
||||
|
||||
template<typename Assignment>
|
||||
update_t& add_set(Assignment&& assignment)
|
||||
update_t& add_set(Assignment assignment)
|
||||
{
|
||||
static_assert(is_dynamic_t<Assignments>::value, "cannot call add_set() in a non-dynamic set");
|
||||
|
||||
_assignments.add(std::forward<Assignment>(assignment));
|
||||
_assignments.add(assignment);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename... Expr>
|
||||
auto where(Expr&&... expr)
|
||||
-> set_where_t<vendor::where_t<void, typename std::decay<Expr>::type...>>
|
||||
auto where(Expr... expr)
|
||||
-> set_where_t<vendor::where_t<void, Expr...>>
|
||||
{
|
||||
static_assert(not vendor::is_noop<Assignments>::value, "cannot call where() if set() hasn't been called yet");
|
||||
static_assert(vendor::is_noop<Where>::value, "cannot call where() twice");
|
||||
return {
|
||||
_table,
|
||||
_assignments,
|
||||
{std::tuple<typename std::decay<Expr>::type...>{std::forward<Expr>(expr)...}},
|
||||
{std::tuple<Expr...>{expr...}},
|
||||
};
|
||||
}
|
||||
|
||||
template<typename... Expr>
|
||||
auto dynamic_where(Expr&&... expr)
|
||||
-> set_where_t<vendor::where_t<Database, typename std::decay<Expr>::type...>>
|
||||
auto dynamic_where(Expr... expr)
|
||||
-> set_where_t<vendor::where_t<Database, Expr...>>
|
||||
{
|
||||
static_assert(not vendor::is_noop<Assignments>::value, "cannot call where() if set() hasn't been called yet");
|
||||
static_assert(vendor::is_noop<Where>::value, "cannot call where() twice");
|
||||
return {
|
||||
_table,
|
||||
_assignments,
|
||||
{std::tuple<typename std::decay<Expr>::type...>{std::forward<Expr>(expr)...}},
|
||||
{std::tuple<Expr...>{expr...}},
|
||||
};
|
||||
}
|
||||
|
||||
template<typename Expr>
|
||||
update_t& add_where(Expr&& expr)
|
||||
update_t& add_where(Expr expr)
|
||||
{
|
||||
static_assert(is_dynamic_t<Where>::value, "cannot call add_where() in a non-dynamic where");
|
||||
|
||||
_where.add(std::forward<Expr>(expr));
|
||||
_where.add(expr);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename Db>
|
||||
std::size_t run(Db& db) const
|
||||
std::size_t _run(Db& db) const
|
||||
{
|
||||
static_assert(not vendor::is_noop<Assignments>::value, "calling set() required before running update");
|
||||
static_assert(is_where_t<Where>::value, "cannot run update without having a where condition, use .where(true) to update all rows");
|
||||
@@ -154,8 +154,8 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename Db>
|
||||
auto prepare(Db& db) const
|
||||
-> prepared_update_t<typename std::decay<Db>::type, update_t>
|
||||
auto _prepare(Db& db) const
|
||||
-> prepared_update_t<Db, update_t>
|
||||
{
|
||||
static_assert(not vendor::is_noop<Assignments>::value, "calling set() required before running update");
|
||||
|
||||
@@ -191,15 +191,15 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename Table>
|
||||
constexpr update_t<void, typename std::decay<Table>::type> update(Table&& table)
|
||||
constexpr update_t<void, Table> update(Table table)
|
||||
{
|
||||
return {std::forward<Table>(table)};
|
||||
return {table};
|
||||
}
|
||||
|
||||
template<typename Db, typename Table>
|
||||
constexpr update_t<typename std::decay<Db>::type, typename std::decay<Table>::type> dynamic_update(Db&& db, Table&& table)
|
||||
constexpr update_t<Db, Table> dynamic_update(const Db&, Table table)
|
||||
{
|
||||
return {std::forward<Table>(table)};
|
||||
return {table};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
12
include/sqlpp11/vendor/expression.h
vendored
12
include/sqlpp11/vendor/expression.h
vendored
@@ -40,9 +40,9 @@ namespace sqlpp
|
||||
namespace vendor
|
||||
{
|
||||
template<typename Lhs, typename Rhs>
|
||||
struct equal_t: public detail::boolean::template operators<equal_t<Lhs, Rhs>>
|
||||
struct equal_t: public ::sqlpp::detail::boolean::template operators<equal_t<Lhs, Rhs>>
|
||||
{
|
||||
using _value_type = detail::boolean;
|
||||
using _value_type = ::sqlpp::detail::boolean;
|
||||
using _parameter_tuple_t = std::tuple<Lhs, Rhs>;
|
||||
|
||||
equal_t(Lhs lhs, Rhs rhs):
|
||||
@@ -84,9 +84,9 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
struct not_equal_t: public detail::boolean::template operators<not_equal_t<Lhs, Rhs>>
|
||||
struct not_equal_t: public ::sqlpp::detail::boolean::template operators<not_equal_t<Lhs, Rhs>>
|
||||
{
|
||||
using _value_type = detail::boolean;
|
||||
using _value_type = ::sqlpp::detail::boolean;
|
||||
using _parameter_tuple_t = std::tuple<Lhs, Rhs>;
|
||||
|
||||
not_equal_t(Lhs lhs, Rhs rhs):
|
||||
@@ -128,9 +128,9 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template<typename Lhs>
|
||||
struct logical_not_t: public detail::boolean::template operators<logical_not_t<Lhs>>
|
||||
struct logical_not_t: public ::sqlpp::detail::boolean::template operators<logical_not_t<Lhs>>
|
||||
{
|
||||
using _value_type = detail::boolean;
|
||||
using _value_type = ::sqlpp::detail::boolean;
|
||||
using _parameter_tuple_t = std::tuple<Lhs>;
|
||||
|
||||
logical_not_t(Lhs l):
|
||||
|
||||
16
include/sqlpp11/vendor/expression_fwd.h
vendored
16
include/sqlpp11/vendor/expression_fwd.h
vendored
@@ -44,37 +44,37 @@ namespace sqlpp
|
||||
{
|
||||
struct less_than
|
||||
{
|
||||
using _value_type = detail::boolean;
|
||||
using _value_type = ::sqlpp::detail::boolean;
|
||||
static constexpr const char* _name = "<";
|
||||
};
|
||||
|
||||
struct less_equal
|
||||
{
|
||||
using _value_type = detail::boolean;
|
||||
using _value_type = ::sqlpp::detail::boolean;
|
||||
static constexpr const char* _name = "<=";
|
||||
};
|
||||
|
||||
struct greater_equal
|
||||
{
|
||||
using _value_type = detail::boolean;
|
||||
using _value_type = ::sqlpp::detail::boolean;
|
||||
static constexpr const char* _name = ">=";
|
||||
};
|
||||
|
||||
struct greater_than
|
||||
{
|
||||
using _value_type = detail::boolean;
|
||||
using _value_type = ::sqlpp::detail::boolean;
|
||||
static constexpr const char* _name = ">";
|
||||
};
|
||||
|
||||
struct logical_or
|
||||
{
|
||||
using _value_type = detail::boolean;
|
||||
using _value_type = ::sqlpp::detail::boolean;
|
||||
static constexpr const char* _name = " OR ";
|
||||
};
|
||||
|
||||
struct logical_and
|
||||
{
|
||||
using _value_type = detail::boolean;
|
||||
using _value_type = ::sqlpp::detail::boolean;
|
||||
static constexpr const char* _name = " AND ";
|
||||
};
|
||||
|
||||
@@ -101,13 +101,13 @@ namespace sqlpp
|
||||
|
||||
struct divides
|
||||
{
|
||||
using _value_type = detail::floating_point;
|
||||
using _value_type = ::sqlpp::detail::floating_point;
|
||||
static constexpr const char* _name = "/";
|
||||
};
|
||||
|
||||
struct modulus
|
||||
{
|
||||
using _value_type = detail::integral;
|
||||
using _value_type = ::sqlpp::detail::integral;
|
||||
static constexpr const char* _name = "%";
|
||||
};
|
||||
|
||||
|
||||
6
include/sqlpp11/vendor/from.h
vendored
6
include/sqlpp11/vendor/from.h
vendored
@@ -56,10 +56,10 @@ namespace sqlpp
|
||||
// FIXME: Joins contain two tables. This is not being dealt with at the moment when looking at duplicates, for instance
|
||||
|
||||
template<typename Table>
|
||||
void add(Table&& table)
|
||||
void add(Table table)
|
||||
{
|
||||
static_assert(is_table_t<typename std::decay<Table>::type>::value, "from arguments require to be tables or joins");
|
||||
_dynamic_tables.emplace_back(std::forward<Table>(table));
|
||||
static_assert(is_table_t<Table>::value, "from arguments require to be tables or joins");
|
||||
_dynamic_tables.emplace_back(table);
|
||||
}
|
||||
|
||||
std::tuple<TableOrJoin...> _tables;
|
||||
|
||||
6
include/sqlpp11/vendor/group_by.h
vendored
6
include/sqlpp11/vendor/group_by.h
vendored
@@ -56,10 +56,10 @@ namespace sqlpp
|
||||
static_assert(_valid_expressions::size::value == sizeof...(Expr), "at least one argument is not an expression in group_by()");
|
||||
|
||||
template<typename E>
|
||||
void add(E&& expr)
|
||||
void add(E expr)
|
||||
{
|
||||
static_assert(is_table_t<typename std::decay<E>::type>::value, "from arguments require to be tables or joins");
|
||||
_dynamic_expressions.emplace_back(std::forward<E>(expr));
|
||||
static_assert(is_table_t<E>::value, "from arguments require to be tables or joins");
|
||||
_dynamic_expressions.emplace_back(expr);
|
||||
}
|
||||
|
||||
_parameter_tuple_t _expressions;
|
||||
|
||||
6
include/sqlpp11/vendor/having.h
vendored
6
include/sqlpp11/vendor/having.h
vendored
@@ -51,10 +51,10 @@ namespace sqlpp
|
||||
using _parameter_list_t = typename make_parameter_list_t<_parameter_tuple_t>::type;
|
||||
|
||||
template<typename E>
|
||||
void add(E&& expr)
|
||||
void add(E expr)
|
||||
{
|
||||
static_assert(is_expression_t<typename std::decay<E>::type>::value, "invalid expression argument in add_having()");
|
||||
_dynamic_expressions.emplace_back(std::forward<E>(expr));
|
||||
static_assert(is_expression_t<E>::value, "invalid expression argument in add_having()");
|
||||
_dynamic_expressions.emplace_back(expr);
|
||||
}
|
||||
|
||||
_parameter_tuple_t _expressions;
|
||||
|
||||
10
include/sqlpp11/vendor/insert_list.h
vendored
10
include/sqlpp11/vendor/insert_list.h
vendored
@@ -88,12 +88,12 @@ namespace sqlpp
|
||||
~insert_list_t() = default;
|
||||
|
||||
template<typename Assignment>
|
||||
void add(Assignment&& assignment)
|
||||
void add(Assignment assignment)
|
||||
{
|
||||
static_assert(is_assignment_t<typename std::decay<Assignment>::type>::value, "set() arguments require to be assigments");
|
||||
static_assert(not must_not_insert_t<typename std::decay<Assignment>::type>::value, "set() argument must not be used in insert");
|
||||
_dynamic_columns.emplace_back(simple_column_t<typename Assignment::_column_t>{std::forward<typename Assignment::_column_t>(assignment._lhs)});
|
||||
_dynamic_values.emplace_back(std::forward<typename Assignment::value_type>(assignment._rhs));
|
||||
static_assert(is_assignment_t<Assignment>::value, "set() arguments require to be assigments");
|
||||
static_assert(not must_not_insert_t<Assignment>::value, "set() argument must not be used in insert");
|
||||
_dynamic_columns.emplace_back(simple_column_t<typename Assignment::_column_t>{assignment._lhs});
|
||||
_dynamic_values.emplace_back(assignment._rhs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
4
include/sqlpp11/vendor/interpret_tuple.h
vendored
4
include/sqlpp11/vendor/interpret_tuple.h
vendored
@@ -68,9 +68,9 @@ namespace sqlpp
|
||||
|
||||
template<typename Tuple, typename Separator, typename Context>
|
||||
auto interpret_tuple(const Tuple& t, const Separator& separator, Context& context)
|
||||
-> decltype(tuple_interpreter_t<typename std::decay<Context>::type, typename std::decay<Tuple>::type>::_(t, separator, context))
|
||||
-> decltype(tuple_interpreter_t<Context, Tuple>::_(t, separator, context))
|
||||
{
|
||||
return tuple_interpreter_t<typename std::decay<Context>::type, typename std::decay<Tuple>::type>::_(t, separator, context);
|
||||
return tuple_interpreter_t<Context, Tuple>::_(t, separator, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
8
include/sqlpp11/vendor/interpretable.h
vendored
8
include/sqlpp11/vendor/interpretable.h
vendored
@@ -43,7 +43,7 @@ namespace sqlpp
|
||||
|
||||
template<typename T>
|
||||
interpretable_t(T t):
|
||||
_impl(std::make_shared<_impl_t<typename std::decay<T>::type>>(t))
|
||||
_impl(std::make_shared<_impl_t<T>>(t))
|
||||
{}
|
||||
|
||||
interpretable_t(const interpretable_t&) = default;
|
||||
@@ -73,14 +73,10 @@ namespace sqlpp
|
||||
struct _impl_t: public _impl_base
|
||||
{
|
||||
static_assert(not make_parameter_list_t<T>::type::size::value, "parameters not supported in dynamic statement parts");
|
||||
_impl_t(const T& t):
|
||||
_impl_t(T t):
|
||||
_t(t)
|
||||
{}
|
||||
|
||||
_impl_t(T&& t):
|
||||
_t(std::move(t))
|
||||
{}
|
||||
|
||||
sqlpp::serializer_t& interpret(sqlpp::serializer_t& context) const
|
||||
{
|
||||
sqlpp::interpret(_t, context);
|
||||
|
||||
8
include/sqlpp11/vendor/interpretable_list.h
vendored
8
include/sqlpp11/vendor/interpretable_list.h
vendored
@@ -50,9 +50,9 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename Expr>
|
||||
void emplace_back(Expr&& expr)
|
||||
void emplace_back(Expr expr)
|
||||
{
|
||||
_serializables.emplace_back(std::forward<Expr>(expr));
|
||||
_serializables.emplace_back(expr);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -111,9 +111,9 @@ namespace sqlpp
|
||||
|
||||
template<typename T, typename Separator, typename Context>
|
||||
auto interpret_list(const T& t, const Separator& separator, Context& context)
|
||||
-> decltype(serializable_list_interpreter_t<typename std::decay<Context>::type, typename std::decay<T>::type>::_(t, separator, context))
|
||||
-> decltype(serializable_list_interpreter_t<Context, T>::_(t, separator, context))
|
||||
{
|
||||
return serializable_list_interpreter_t<typename std::decay<Context>::type, typename std::decay<T>::type>::_(t, separator, context);
|
||||
return serializable_list_interpreter_t<Context, T>::_(t, separator, context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
4
include/sqlpp11/vendor/interpreter.h
vendored
4
include/sqlpp11/vendor/interpreter.h
vendored
@@ -27,7 +27,7 @@
|
||||
#ifndef SQLPP_VENDOR_INTERPRET_H
|
||||
#define SQLPP_VENDOR_INTERPRET_H
|
||||
|
||||
#include <sqlpp11/detail/wrong.h>
|
||||
#include <sqlpp11/vendor/wrong.h>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
@@ -38,7 +38,7 @@ namespace sqlpp
|
||||
{
|
||||
static void _(const T& t, Context& context)
|
||||
{
|
||||
static_assert(detail::wrong<Context, T>::value, "missing interpreter specialization");
|
||||
static_assert(wrong_t<Context, T>::value, "missing interpreter specialization");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
6
include/sqlpp11/vendor/is_null.h
vendored
6
include/sqlpp11/vendor/is_null.h
vendored
@@ -55,14 +55,10 @@ namespace sqlpp
|
||||
};
|
||||
};
|
||||
|
||||
is_null_t(const Operand& operand):
|
||||
is_null_t(Operand operand):
|
||||
_operand(operand)
|
||||
{}
|
||||
|
||||
is_null_t(Operand&& operand):
|
||||
_operand(std::move(operand))
|
||||
{}
|
||||
|
||||
is_null_t(const is_null_t&) = default;
|
||||
is_null_t(is_null_t&&) = default;
|
||||
is_null_t& operator=(const is_null_t&) = default;
|
||||
|
||||
7
include/sqlpp11/vendor/like.h
vendored
7
include/sqlpp11/vendor/like.h
vendored
@@ -57,12 +57,7 @@ namespace sqlpp
|
||||
};
|
||||
};
|
||||
|
||||
like_t(Operand&& operand, Pattern&& pattern):
|
||||
_operand(std::move(operand)),
|
||||
_pattern(std::move(pattern))
|
||||
{}
|
||||
|
||||
like_t(const Operand& operand, const Pattern& pattern):
|
||||
like_t(Operand operand, Pattern pattern):
|
||||
_operand(operand),
|
||||
_pattern(pattern)
|
||||
{}
|
||||
|
||||
8
include/sqlpp11/vendor/named_interpretable.h
vendored
8
include/sqlpp11/vendor/named_interpretable.h
vendored
@@ -42,7 +42,7 @@ namespace sqlpp
|
||||
|
||||
template<typename T>
|
||||
named_interpretable_t(T t):
|
||||
_impl(std::make_shared<_impl_t<typename std::decay<T>::type>>(t))
|
||||
_impl(std::make_shared<_impl_t<T>>(t))
|
||||
{}
|
||||
|
||||
named_interpretable_t(const named_interpretable_t&) = default;
|
||||
@@ -78,14 +78,10 @@ namespace sqlpp
|
||||
struct _impl_t: public _impl_base
|
||||
{
|
||||
static_assert(not make_parameter_list_t<T>::type::size::value, "parameters not supported in dynamic statement parts");
|
||||
_impl_t(const T& t):
|
||||
_impl_t(T t):
|
||||
_t(t)
|
||||
{}
|
||||
|
||||
_impl_t(T&& t):
|
||||
_t(std::move(t))
|
||||
{}
|
||||
|
||||
sqlpp::serializer_t& interpret(sqlpp::serializer_t& context) const
|
||||
{
|
||||
sqlpp::interpret(_t, context);
|
||||
|
||||
6
include/sqlpp11/vendor/order_by.h
vendored
6
include/sqlpp11/vendor/order_by.h
vendored
@@ -55,10 +55,10 @@ namespace sqlpp
|
||||
static_assert(_valid_expressions::size::value == sizeof...(Expr), "at least one argument is not a sort order expression in order_by()");
|
||||
|
||||
template<typename E>
|
||||
void add(E&& expr)
|
||||
void add(E expr)
|
||||
{
|
||||
static_assert(is_sort_order_t<typename std::decay<E>::type>::value, "order_by arguments require to be sort-order expressions");
|
||||
_dynamic_expressions.push_back(std::forward<E>(expr));
|
||||
static_assert(is_sort_order_t<E>::value, "order_by arguments require to be sort-order expressions");
|
||||
_dynamic_expressions.push_back(expr);
|
||||
}
|
||||
|
||||
_parameter_tuple_t _expressions;
|
||||
|
||||
14
include/sqlpp11/vendor/select_column_list.h
vendored
14
include/sqlpp11/vendor/select_column_list.h
vendored
@@ -68,10 +68,10 @@ namespace sqlpp
|
||||
_names_t _dynamic_expression_names;
|
||||
|
||||
template<typename Expr>
|
||||
void push_back(Expr&& expr)
|
||||
void push_back(Expr expr)
|
||||
{
|
||||
_dynamic_expression_names.push_back(std::decay<Expr>::type::_name_t::_get_name());
|
||||
_dynamic_columns.emplace_back(std::forward<Expr>(expr));
|
||||
_dynamic_expression_names.push_back(Expr::_name_t::_get_name());
|
||||
_dynamic_columns.emplace_back(expr);
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
@@ -133,7 +133,7 @@ namespace sqlpp
|
||||
template<typename Database, typename T>
|
||||
struct select_column_list_t
|
||||
{
|
||||
static_assert(::sqlpp::detail::wrong<Database, T>::value, "invalid template argument for select_column_list");
|
||||
static_assert(::sqlpp::vendor::wrong_t<Database, T>::value, "invalid template argument for select_column_list");
|
||||
};
|
||||
|
||||
template<typename Database, typename... NamedExpr>
|
||||
@@ -179,11 +179,11 @@ namespace sqlpp
|
||||
using _dynamic_t = select_column_list_t<Db, std::tuple<NamedExpr...>>;
|
||||
|
||||
template<typename Expr>
|
||||
void add(Expr&& namedExpr)
|
||||
void add(Expr namedExpr)
|
||||
{
|
||||
static_assert(is_named_expression_t<typename std::decay<Expr>::type>::value, "select() arguments require to be named expressions");
|
||||
static_assert(is_named_expression_t<Expr>::value, "select() arguments require to be named expressions");
|
||||
static_assert(_is_dynamic::value, "cannot add columns to a non-dynamic column list");
|
||||
_dynamic_columns.push_back(std::forward<Expr>(namedExpr));
|
||||
_dynamic_columns.push_back(namedExpr);
|
||||
}
|
||||
|
||||
_parameter_tuple_t _columns;
|
||||
|
||||
8
include/sqlpp11/vendor/select_flag_list.h
vendored
8
include/sqlpp11/vendor/select_flag_list.h
vendored
@@ -41,7 +41,7 @@ namespace sqlpp
|
||||
template<typename Database, typename T>
|
||||
struct select_flag_list_t
|
||||
{
|
||||
static_assert(::sqlpp::detail::wrong<T>::value, "invalid argument for select_flag_list");
|
||||
static_assert(::sqlpp::vendor::wrong_t<T>::value, "invalid argument for select_flag_list");
|
||||
};
|
||||
|
||||
// select_flag_list_t
|
||||
@@ -61,10 +61,10 @@ namespace sqlpp
|
||||
static_assert(_valid_flags::size::value == sizeof...(Flag), "at least one argument is not a select flag in select flag list");
|
||||
|
||||
template<typename E>
|
||||
void add(E&& expr)
|
||||
void add(E expr)
|
||||
{
|
||||
static_assert(is_select_flag_t<typename std::decay<E>::type>::value, "flag arguments require to be select flags");
|
||||
_dynamic_flags.emplace_back(std::forward<E>(expr));
|
||||
static_assert(is_select_flag_t<E>::value, "flag arguments require to be select flags");
|
||||
_dynamic_flags.emplace_back(expr);
|
||||
}
|
||||
|
||||
_parameter_tuple_t _flags;
|
||||
|
||||
7
include/sqlpp11/vendor/select_pseudo_table.h
vendored
7
include/sqlpp11/vendor/select_pseudo_table.h
vendored
@@ -51,16 +51,11 @@ namespace sqlpp
|
||||
using _value_type = no_value_t;
|
||||
using _is_pseudo_table = std::true_type;
|
||||
|
||||
select_pseudo_table_t(const Select& select):
|
||||
select_pseudo_table_t(Select select):
|
||||
_select(select)
|
||||
{
|
||||
}
|
||||
|
||||
select_pseudo_table_t(Select&& select):
|
||||
_select(std::move(select))
|
||||
{
|
||||
}
|
||||
|
||||
select_pseudo_table_t(const select_pseudo_table_t& rhs) = default;
|
||||
select_pseudo_table_t(select_pseudo_table_t&& rhs) = default;
|
||||
select_pseudo_table_t& operator=(const select_pseudo_table_t& rhs) = default;
|
||||
|
||||
8
include/sqlpp11/vendor/update_list.h
vendored
8
include/sqlpp11/vendor/update_list.h
vendored
@@ -58,11 +58,11 @@ namespace sqlpp
|
||||
static_assert(_prohibited_assignment_set::size::value == 0, "at least one assignment is prohibited by its column definition in set()");
|
||||
|
||||
template<typename Assignment>
|
||||
void add(Assignment&& assignment)
|
||||
void add(Assignment assignment)
|
||||
{
|
||||
static_assert(is_assignment_t<typename std::decay<Assignment>::type>::value, "set() arguments require to be assigments");
|
||||
static_assert(not must_not_update_t<typename std::decay<Assignment>::type::_column_t>::value, "set() argument must not be updated");
|
||||
_dynamic_assignments.emplace_back(std::forward<Assignment>(assignment));
|
||||
static_assert(is_assignment_t<Assignment>::value, "set() arguments require to be assigments");
|
||||
static_assert(not must_not_update_t<typename Assignment::_column_t>::value, "set() argument must not be updated");
|
||||
_dynamic_assignments.emplace_back(assignment);
|
||||
}
|
||||
|
||||
_parameter_tuple_t _assignments;
|
||||
|
||||
6
include/sqlpp11/vendor/using.h
vendored
6
include/sqlpp11/vendor/using.h
vendored
@@ -54,10 +54,10 @@ namespace sqlpp
|
||||
|
||||
|
||||
template<typename T>
|
||||
void add(T&& table)
|
||||
void add(T table)
|
||||
{
|
||||
static_assert(is_table_t<typename std::decay<T>::type>::value, "using() arguments require to be tables");
|
||||
_dynamic_tables.emplace_back(std::forward<T>(table));
|
||||
static_assert(is_table_t<T>::value, "using() arguments require to be tables");
|
||||
_dynamic_tables.emplace_back(table);
|
||||
}
|
||||
|
||||
_parameter_tuple_t _tables;
|
||||
|
||||
2
include/sqlpp11/vendor/value_type.h
vendored
2
include/sqlpp11/vendor/value_type.h
vendored
@@ -35,7 +35,7 @@ namespace sqlpp
|
||||
namespace vendor
|
||||
{
|
||||
template<typename T>
|
||||
using value_type_t = typename wrap_operand<typename std::decay<T>::type>::type::_value_type;
|
||||
using value_type_t = typename wrap_operand<T>::type::_value_type;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
6
include/sqlpp11/vendor/where.h
vendored
6
include/sqlpp11/vendor/where.h
vendored
@@ -54,10 +54,10 @@ namespace sqlpp
|
||||
using _parameter_list_t = typename make_parameter_list_t<_parameter_tuple_t>::type;
|
||||
|
||||
template<typename E>
|
||||
void add(E&& expr)
|
||||
void add(E expr)
|
||||
{
|
||||
static_assert(is_expression_t<typename std::decay<E>::type>::value, "invalid expression argument in add_where()");
|
||||
_dynamic_expressions.emplace_back(std::forward<E>(expr));
|
||||
static_assert(is_expression_t<E>::value, "invalid expression argument in add_where()");
|
||||
_dynamic_expressions.emplace_back(expr);
|
||||
}
|
||||
|
||||
_parameter_tuple_t _expressions;
|
||||
|
||||
8
include/sqlpp11/vendor/wrap_operand.h
vendored
8
include/sqlpp11/vendor/wrap_operand.h
vendored
@@ -45,7 +45,7 @@ namespace sqlpp
|
||||
struct boolean_operand
|
||||
{
|
||||
static constexpr bool _is_expression = true;
|
||||
using _value_type = detail::boolean;
|
||||
using _value_type = sqlpp::detail::boolean;
|
||||
|
||||
bool _is_trivial() const { return _t == false; }
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace sqlpp
|
||||
struct integral_operand
|
||||
{
|
||||
static constexpr bool _is_expression = true;
|
||||
using _value_type = detail::integral;
|
||||
using _value_type = ::sqlpp::detail::integral;
|
||||
|
||||
bool _is_trivial() const { return _t == 0; }
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace sqlpp
|
||||
struct floating_point_operand
|
||||
{
|
||||
static constexpr bool _is_expression = true;
|
||||
using _value_type = detail::floating_point;
|
||||
using _value_type = ::sqlpp::detail::floating_point;
|
||||
|
||||
bool _is_trivial() const { return _t == 0; }
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace sqlpp
|
||||
struct text_operand
|
||||
{
|
||||
static constexpr bool _is_expression = true;
|
||||
using _value_type = detail::text;
|
||||
using _value_type = ::sqlpp::detail::text;
|
||||
|
||||
bool _is_trivial() const { return _t.empty(); }
|
||||
|
||||
|
||||
@@ -24,19 +24,29 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_DETAIL_WRONG_H
|
||||
#define SQLPP_DETAIL_WRONG_H
|
||||
#ifndef SQLPP_VENDOR_WRONG_H
|
||||
#define SQLPP_VENDOR_WRONG_H
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
namespace detail
|
||||
namespace vendor
|
||||
{
|
||||
// A template that always returns false
|
||||
// To be used with static assert, for instance, to ensure it
|
||||
// fires only when the template is instantiated.
|
||||
template<class ...T> struct wrong : std::false_type {};
|
||||
namespace detail
|
||||
{
|
||||
// A template that always returns false
|
||||
// To be used with static assert, for instance, to ensure it
|
||||
// fires only when the template is instantiated.
|
||||
template<class ...T> struct wrong_t
|
||||
{
|
||||
using type = std::false_type;
|
||||
};
|
||||
}
|
||||
|
||||
template<class ...T>
|
||||
using wrong_t = typename detail::wrong_t<T...>::type;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user