0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Everything compiles again.

This commit is contained in:
rbock 2016-09-01 21:38:36 +02:00
parent 637e0ad4d9
commit 1a0f0ea0ab
13 changed files with 162 additions and 187 deletions

View File

@ -27,7 +27,6 @@
#ifndef SQLPP_POLICY_UPDATE_H #ifndef SQLPP_POLICY_UPDATE_H
#define SQLPP_POLICY_UPDATE_H #define SQLPP_POLICY_UPDATE_H
#include <sqlpp11/bad_statement.h>
#include <sqlpp11/wrong.h> #include <sqlpp11/wrong.h>
namespace sqlpp namespace sqlpp

View File

@ -27,7 +27,6 @@
#ifndef SQLPP_PRE_JOIN_H #ifndef SQLPP_PRE_JOIN_H
#define SQLPP_PRE_JOIN_H #define SQLPP_PRE_JOIN_H
#include <sqlpp11/bad_statement.h>
#include <sqlpp11/join_types.h> #include <sqlpp11/join_types.h>
#include <sqlpp11/noop.h> #include <sqlpp11/noop.h>
#include <sqlpp11/on.h> #include <sqlpp11/on.h>
@ -144,18 +143,38 @@ namespace sqlpp
} }
}; };
template <typename Lhs, typename Rhs> namespace detail
auto join(Lhs lhs, Rhs rhs) -> typename std::
conditional<check_pre_join_t<Lhs, Rhs>::value, pre_join_t<inner_join_t, Lhs, Rhs>, bad_statement>::type
{ {
check_pre_join_t<Lhs, Rhs>{}; // FIXME: Failure return type? template <typename JoinType, typename Check, typename Lhs, typename Rhs>
auto join_impl(Check, Lhs lhs, Rhs rhs) -> Check;
template <typename JoinType, typename Lhs, typename Rhs>
auto join_impl(consistent_t, Lhs lhs, Rhs rhs) -> pre_join_t<JoinType, Lhs, Rhs>;
template <typename JoinType, typename Lhs, typename Rhs>
auto join_impl(Lhs lhs, Rhs rhs) -> decltype(join_impl<JoinType>(check_pre_join_t<Lhs, Rhs>{}, lhs, rhs));
}
template <typename Lhs, typename Rhs>
auto join(Lhs lhs, Rhs rhs) -> decltype(detail::join_impl<inner_join_t>(lhs, rhs))
{
return {lhs, rhs}; return {lhs, rhs};
} }
template <typename Lhs, typename Rhs> template <typename Lhs, typename Rhs>
auto inner_join(Lhs lhs, Rhs rhs) -> typename std:: auto inner_join(Lhs lhs, Rhs rhs) -> decltype(detail::join_impl<inner_join_t>(lhs, rhs))
conditional<check_pre_join_t<Lhs, Rhs>::value, pre_join_t<inner_join_t, Lhs, Rhs>, bad_statement>::type {
return {lhs, rhs};
}
template <typename Lhs, typename Rhs>
auto left_outer_join(Lhs lhs, Rhs rhs) -> decltype(detail::join_impl<left_outer_join_t>(lhs, rhs))
{
return {lhs, rhs};
}
template <typename Lhs, typename Rhs>
auto right_outer_join(Lhs lhs, Rhs rhs) -> decltype(detail::join_impl<right_outer_join_t>(lhs, rhs))
{ {
check_pre_join_t<Lhs, Rhs>{}; check_pre_join_t<Lhs, Rhs>{};
@ -163,40 +182,27 @@ namespace sqlpp
} }
template <typename Lhs, typename Rhs> template <typename Lhs, typename Rhs>
auto left_outer_join(Lhs lhs, Rhs rhs) -> typename std:: auto outer_join(Lhs lhs, Rhs rhs) -> decltype(detail::join_impl<outer_join_t>(lhs, rhs))
conditional<check_pre_join_t<Lhs, Rhs>::value, pre_join_t<left_outer_join_t, Lhs, Rhs>, bad_statement>::type
{ {
check_pre_join_t<Lhs, Rhs>{};
return {lhs, rhs}; return {lhs, rhs};
} }
template <typename Lhs, typename Rhs> namespace detail
auto right_outer_join(Lhs lhs, Rhs rhs) -> typename std::
conditional<check_pre_join_t<Lhs, Rhs>::value, pre_join_t<right_outer_join_t, Lhs, Rhs>, bad_statement>::type
{ {
check_pre_join_t<Lhs, Rhs>{}; template <typename Check, typename Lhs, typename Rhs>
auto cross_join_impl(Check, Lhs lhs, Rhs rhs) -> Check;
return {lhs, rhs}; template <typename Lhs, typename Rhs>
auto cross_join_impl(consistent_t, Lhs lhs, Rhs rhs)
-> join_t<pre_join_t<cross_join_t, Lhs, Rhs>, on_t<unconditional_t>>;
template <typename Lhs, typename Rhs>
auto cross_join_impl(Lhs lhs, Rhs rhs) -> decltype(cross_join_impl(check_pre_join_t<Lhs, Rhs>{}, lhs, rhs));
} }
template <typename Lhs, typename Rhs> template <typename Lhs, typename Rhs>
auto outer_join(Lhs lhs, Rhs rhs) -> typename std:: auto cross_join(Lhs lhs, Rhs rhs) -> decltype(detail::cross_join_impl(lhs, rhs))
conditional<check_pre_join_t<Lhs, Rhs>::value, pre_join_t<outer_join_t, Lhs, Rhs>, bad_statement>::type
{ {
check_pre_join_t<Lhs, Rhs>{};
return {lhs, rhs};
}
template <typename Lhs, typename Rhs>
auto cross_join(Lhs lhs, Rhs rhs) ->
typename std::conditional<check_pre_join_t<Lhs, Rhs>::value,
join_t<pre_join_t<cross_join_t, Lhs, Rhs>, on_t<unconditional_t>>,
bad_statement>::type
{
check_pre_join_t<Lhs, Rhs>{};
return {pre_join_t<cross_join_t, Lhs, Rhs>{lhs, rhs}, {}}; return {pre_join_t<cross_join_t, Lhs, Rhs>{lhs, rhs}, {}};
} }
} }

View File

@ -27,16 +27,16 @@
#ifndef SQLPP_UNION_H #ifndef SQLPP_UNION_H
#define SQLPP_UNION_H #define SQLPP_UNION_H
#include <sqlpp11/union_data.h>
#include <sqlpp11/union_flags.h>
#include <sqlpp11/statement_fwd.h>
#include <sqlpp11/type_traits.h>
#include <sqlpp11/parameter_list.h>
#include <sqlpp11/expression.h> #include <sqlpp11/expression.h>
#include <sqlpp11/interpret_tuple.h> #include <sqlpp11/interpret_tuple.h>
#include <sqlpp11/interpretable_list.h> #include <sqlpp11/interpretable_list.h>
#include <sqlpp11/result_row.h>
#include <sqlpp11/logic.h> #include <sqlpp11/logic.h>
#include <sqlpp11/parameter_list.h>
#include <sqlpp11/result_row.h>
#include <sqlpp11/statement_fwd.h>
#include <sqlpp11/type_traits.h>
#include <sqlpp11/union_data.h>
#include <sqlpp11/union_flags.h>
namespace sqlpp namespace sqlpp
{ {
@ -45,19 +45,19 @@ namespace sqlpp
using blank_union_t = statement_t<void, no_union_t>; using blank_union_t = statement_t<void, no_union_t>;
// There is no order by or limit or offset in union, use it as a pseudo table to do that. // There is no order by or limit or offset in union, use it as a pseudo table to do that.
template <bool, typename Union> template <typename Check, typename Union>
struct union_statement_impl struct union_statement_impl
{
using type = Check;
};
template <typename Union>
struct union_statement_impl<consistent_t, Union>
{ {
using type = statement_t<void, Union, no_union_t>; using type = statement_t<void, Union, no_union_t>;
}; };
template <typename Union> template <typename Check, typename Union>
struct union_statement_impl<false, Union>
{
using type = bad_statement;
};
template <bool Check, typename Union>
using union_statement_t = typename union_statement_impl<Check, Union>::type; using union_statement_t = typename union_statement_impl<Check, Union>::type;
// UNION(EXPR) // UNION(EXPR)
@ -95,8 +95,7 @@ namespace sqlpp
// workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2173269 // workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2173269
template <typename... Args> template <typename... Args>
_base_t(Args&&... args) _base_t(Args&&... args) : union_{std::forward<Args>(args)...}
: union_{std::forward<Args>(args)...}
{ {
} }
@ -166,8 +165,7 @@ namespace sqlpp
// workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2173269 // workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2173269
template <typename... Args> template <typename... Args>
_base_t(Args&&... args) _base_t(Args&&... args) : no_union{std::forward<Args>(args)...}
: no_union{std::forward<Args>(args)...}
{ {
} }
@ -196,7 +194,7 @@ namespace sqlpp
using _check = typename logic::all<is_statement_t<T>::value...>::type; using _check = typename logic::all<is_statement_t<T>::value...>::type;
template <typename Check, typename T> template <typename Check, typename T>
using _new_statement_t = union_statement_t<Check::value, T>; using _new_statement_t = union_statement_t<Check, T>;
using _consistency_check = consistent_t; using _consistency_check = consistent_t;
@ -237,16 +235,15 @@ namespace sqlpp
} }
private: private:
template <typename Database, typename Flag, typename Rhs> template <typename Database, typename Check, typename Flag, typename Rhs>
auto _union_impl(const std::false_type&, Rhs rhs) const -> bad_statement; auto _union_impl(Check, Rhs rhs) const -> Check;
template <typename Database, typename Flag, typename Rhs> template <typename Database, typename Flag, typename Rhs>
auto _union_impl(const std::true_type&, Rhs rhs) const auto _union_impl(consistent_t, Rhs rhs) const
-> _new_statement_t<std::true_type, union_t<Database, Flag, derived_statement_t<Policies>, Rhs>> -> _new_statement_t<consistent_t, union_t<Database, Flag, derived_statement_t<Policies>, Rhs>>
{ {
return {blank_union_t{}, return {blank_union_t{}, union_data_t<Database, Flag, derived_statement_t<Policies>, Rhs>{
union_data_t<Database, Flag, derived_statement_t<Policies>, Rhs>{ static_cast<const derived_statement_t<Policies>&>(*this), rhs}};
static_cast<const derived_statement_t<Policies>&>(*this), rhs}};
} }
}; };
}; };

View File

@ -23,104 +23,95 @@
* OF THE POSSIBILITY OF SUCH DAMAGE. * OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <iostream>
#include "Sample.h"
#include "MockDb.h" #include "MockDb.h"
#include "Sample.h"
#include <iostream>
#include <sqlpp11/alias_provider.h> #include <sqlpp11/alias_provider.h>
#include <sqlpp11/select.h>
#include <sqlpp11/functions.h>
#include <sqlpp11/connection.h> #include <sqlpp11/connection.h>
#include <sqlpp11/functions.h>
namespace sqlpp #include <sqlpp11/select.h>
{
namespace test
{
template <typename T>
void print_type_on_error(std::true_type, const T&)
{
}
template <typename T>
void print_type_on_error(std::false_type, const T& t)
{
t._print_me_;
}
template <typename Assert, typename Expression>
void run_check(const Expression&)
{
using Context = MockDb::_serializer_context_t;
using CheckResult = std::is_same<sqlpp::run_check_t<Context, Expression>, Assert>;
static_assert(CheckResult::value, "Unexpected run_check result");
print_type_on_error(CheckResult{}, sqlpp::run_check_t<Context, Expression>{});
}
template <typename Expression>
void run_check(const Expression&)
{
using Context = MockDb::_serializer_context_t;
using CheckResult = std::is_same<sqlpp::run_check_t<Context, Expression>, consistent_t>;
static_assert(CheckResult::value, "Unexpected run_check result");
print_type_on_error(CheckResult{}, sqlpp::run_check_t<Context, Expression>{});
}
}
}
namespace namespace
{ {
template <typename T>
void print_type_on_error(std::true_type)
{
}
template <typename T>
void print_type_on_error(std::false_type)
{
T::_print_me_;
}
template <typename Assert, typename Expression>
void static_run_check(const Expression&)
{
using Context = MockDb::_serializer_context_t;
using CheckResult = sqlpp::run_check_t<Context, Expression>;
using ExpectedCheckResult = std::is_same<CheckResult, Assert>;
print_type_on_error<CheckResult>(ExpectedCheckResult{});
static_assert(ExpectedCheckResult::value, "Unexpected check result");
}
SQLPP_ALIAS_PROVIDER(whatever) SQLPP_ALIAS_PROVIDER(whatever)
using sqlpp::test::run_check;
static constexpr auto t = test::TabBar{}; static constexpr auto t = test::TabBar{};
// If there is no group_by, we can select whatever we want // If there is no group_by, we can select whatever we want
void no_group_by() void no_group_by()
{ {
run_check(select(all_of(t)).from(t).unconditionally()); static_run_check<sqlpp::consistent_t>(select(all_of(t)).from(t).unconditionally());
run_check(select(t.alpha).from(t).unconditionally()); static_run_check<sqlpp::consistent_t>(select(t.alpha).from(t).unconditionally());
run_check(select(count(t.alpha)).from(t).unconditionally()); static_run_check<sqlpp::consistent_t>(select(count(t.alpha)).from(t).unconditionally());
} }
// If there is a dynamic group_by, we can still select whatever we want // If there is a dynamic group_by, we can still select whatever we want
// because there is no way of knowing which expressions might have been added dynamically // because there is no way of knowing which expressions might have been added dynamically
void dynamic_group_by() void dynamic_group_by()
{ {
run_check(select(all_of(t)).from(t).unconditionally()); static_run_check<sqlpp::consistent_t>(select(all_of(t)).from(t).unconditionally());
run_check(select(t.alpha).from(t).unconditionally()); static_run_check<sqlpp::consistent_t>(select(t.alpha).from(t).unconditionally());
run_check(select(count(t.alpha)).from(t).unconditionally()); static_run_check<sqlpp::consistent_t>(select(count(t.alpha)).from(t).unconditionally());
} }
// If there is a static group_by, selected columns must be made of group_by expressions, or aggregate expression (e.g. // If there is a static group_by, selected columns must be made of group_by expressions, or aggregate expression (e.g.
// count(t.id)) or values to be valid // count(t.id)) or values to be valid
void static_group_by_ok() void static_group_by_ok()
{ {
run_check(select(t.alpha).from(t).unconditionally().group_by(t.alpha)); static_run_check<sqlpp::consistent_t>(select(t.alpha).from(t).unconditionally().group_by(t.alpha));
run_check(select((t.alpha + 42).as(whatever)).from(t).unconditionally().group_by(t.alpha)); static_run_check<sqlpp::consistent_t>(
run_check(select((t.alpha + 42).as(whatever)).from(t).unconditionally().group_by(t.alpha, t.alpha + t.delta * 17)); select((t.alpha + 42).as(whatever)).from(t).unconditionally().group_by(t.alpha));
run_check(select((t.alpha + t.delta * 17).as(whatever)) static_run_check<sqlpp::consistent_t>(
.from(t) select((t.alpha + 42).as(whatever)).from(t).unconditionally().group_by(t.alpha, t.alpha + t.delta * 17));
.unconditionally() static_run_check<sqlpp::consistent_t>(select((t.alpha + t.delta * 17).as(whatever))
.group_by(t.alpha, t.alpha + t.delta * 17)); .from(t)
run_check(select((t.beta + "fortytwo").as(whatever)).from(t).unconditionally().group_by(t.beta)); .unconditionally()
.group_by(t.alpha, t.alpha + t.delta * 17));
static_run_check<sqlpp::consistent_t>(
select((t.beta + "fortytwo").as(whatever)).from(t).unconditionally().group_by(t.beta));
run_check(select(avg(t.alpha)).from(t).unconditionally().group_by(t.beta)); static_run_check<sqlpp::consistent_t>(select(avg(t.alpha)).from(t).unconditionally().group_by(t.beta));
run_check(select(count(t.alpha)).from(t).unconditionally().group_by(t.beta)); static_run_check<sqlpp::consistent_t>(select(count(t.alpha)).from(t).unconditionally().group_by(t.beta));
run_check(select(max(t.alpha)).from(t).unconditionally().group_by(t.beta)); static_run_check<sqlpp::consistent_t>(select(max(t.alpha)).from(t).unconditionally().group_by(t.beta));
run_check(select(min(t.alpha)).from(t).unconditionally().group_by(t.beta)); static_run_check<sqlpp::consistent_t>(select(min(t.alpha)).from(t).unconditionally().group_by(t.beta));
run_check(select(sum(t.alpha)).from(t).unconditionally().group_by(t.beta)); static_run_check<sqlpp::consistent_t>(select(sum(t.alpha)).from(t).unconditionally().group_by(t.beta));
run_check(select((t.alpha + count(t.delta)).as(whatever)).from(t).unconditionally().group_by(t.alpha)); static_run_check<sqlpp::consistent_t>(
select((t.alpha + count(t.delta)).as(whatever)).from(t).unconditionally().group_by(t.alpha));
run_check(select(sqlpp::value(1).as(whatever)).from(t).unconditionally().group_by(t.alpha)); static_run_check<sqlpp::consistent_t>(
run_check(select(sqlpp::value("whatever").as(whatever)).from(t).unconditionally().group_by(t.alpha)); select(sqlpp::value(1).as(whatever)).from(t).unconditionally().group_by(t.alpha));
static_run_check<sqlpp::consistent_t>(
select(sqlpp::value("whatever").as(whatever)).from(t).unconditionally().group_by(t.alpha));
} }
// Failures with static group_by and selected non-aggregates or incorrect aggregates // Failures with static group_by and selected non-aggregates or incorrect aggregates
void static_group_by_nok() void static_group_by_nok()
{ {
run_check<sqlpp::assert_no_unknown_aggregates_t>(select(t.beta).from(t).unconditionally().group_by(t.alpha)); static_run_check<sqlpp::assert_no_unknown_aggregates_t>(select(t.beta).from(t).unconditionally().group_by(t.alpha));
run_check<sqlpp::assert_no_unknown_aggregates_t>( static_run_check<sqlpp::assert_no_unknown_aggregates_t>(
select((t.alpha + t.delta).as(whatever)).from(t).unconditionally().group_by(t.alpha)); select((t.alpha + t.delta).as(whatever)).from(t).unconditionally().group_by(t.alpha));
run_check<sqlpp::assert_no_unknown_aggregates_t>( static_run_check<sqlpp::assert_no_unknown_aggregates_t>(
select((t.alpha + t.delta).as(whatever)).from(t).unconditionally().group_by(t.alpha, t.alpha + t.delta * 17)); select((t.alpha + t.delta).as(whatever)).from(t).unconditionally().group_by(t.alpha, t.alpha + t.delta * 17));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015-2015, Roland Bock * Copyright (c) 2015-2016, Roland Bock
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
@ -23,9 +23,9 @@
* OF THE POSSIBILITY OF SUCH DAMAGE. * OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <iostream>
#include "MockDb.h" #include "MockDb.h"
#include "Sample.h" #include "Sample.h"
#include <iostream>
#include <sqlpp11/sqlpp11.h> #include <sqlpp11/sqlpp11.h>
namespace namespace
@ -52,7 +52,7 @@ namespace
static_assert(ExpectedCheckResult::value, "Unexpected check result"); static_assert(ExpectedCheckResult::value, "Unexpected check result");
using ReturnType = decltype(sqlpp::case_when(when)); using ReturnType = decltype(sqlpp::case_when(when));
using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, void>::value>; using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, Assert>::value>;
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }
@ -66,7 +66,7 @@ namespace
static_assert(ExpectedCheckResult::value, "Unexpected check result"); static_assert(ExpectedCheckResult::value, "Unexpected check result");
using ReturnType = decltype(sqlpp::case_when(when).then(then)); using ReturnType = decltype(sqlpp::case_when(when).then(then));
using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, void>::value>; using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, Assert>::value>;
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }
@ -80,7 +80,7 @@ namespace
static_assert(ExpectedCheckResult::value, "Unexpected check result"); static_assert(ExpectedCheckResult::value, "Unexpected check result");
using ReturnType = decltype(sqlpp::case_when(when).then(then).else_(else_)); using ReturnType = decltype(sqlpp::case_when(when).then(then).else_(else_));
using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, void>::value>; using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, Assert>::value>;
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }

View File

@ -23,9 +23,9 @@
* OF THE POSSIBILITY OF SUCH DAMAGE. * OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <iostream>
#include "MockDb.h" #include "MockDb.h"
#include "Sample.h" #include "Sample.h"
#include <iostream>
#include <sqlpp11/sqlpp11.h> #include <sqlpp11/sqlpp11.h>
namespace namespace
@ -53,8 +53,7 @@ namespace
static_assert(ExpectedCheckResult::value, "Unexpected check result"); static_assert(ExpectedCheckResult::value, "Unexpected check result");
using ReturnType = decltype(select(t.alpha).from(expression)); using ReturnType = decltype(select(t.alpha).from(expression));
using ExpectedReturnType = using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, Assert>::value>;
sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, sqlpp::bad_statement>::value>;
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }
@ -69,8 +68,7 @@ namespace
static_assert(ExpectedCheckResult::value, "Unexpected check result"); static_assert(ExpectedCheckResult::value, "Unexpected check result");
using ReturnType = decltype(dynamic_select(db, t.alpha).dynamic_from(expression)); using ReturnType = decltype(dynamic_select(db, t.alpha).dynamic_from(expression));
using ExpectedReturnType = using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, Assert>::value>;
sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, sqlpp::bad_statement>::value>;
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }
@ -120,8 +118,7 @@ namespace
static_assert(ExpectedCheckResult::value, "Unexpected check result"); static_assert(ExpectedCheckResult::value, "Unexpected check result");
using ReturnType = decltype(from.add(expression)); using ReturnType = decltype(from.add(expression));
using ExpectedReturnType = using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, Assert>::value>;
sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, sqlpp::bad_statement>::value>;
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }

View File

@ -23,9 +23,9 @@
* OF THE POSSIBILITY OF SUCH DAMAGE. * OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <iostream>
#include "MockDb.h" #include "MockDb.h"
#include "Sample.h" #include "Sample.h"
#include <iostream>
#include <sqlpp11/sqlpp11.h> #include <sqlpp11/sqlpp11.h>
namespace namespace
@ -53,8 +53,7 @@ namespace
static_assert(ExpectedCheckResult::value, "Unexpected check result"); static_assert(ExpectedCheckResult::value, "Unexpected check result");
using ReturnType = decltype(select(all_of(t)).from(t).unconditionally().group_by(t.alpha).having(expression)); using ReturnType = decltype(select(all_of(t)).from(t).unconditionally().group_by(t.alpha).having(expression));
using ExpectedReturnType = using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, Assert>::value>;
sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, sqlpp::bad_statement>::value>;
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }
@ -70,8 +69,7 @@ namespace
using ReturnType = using ReturnType =
decltype(dynamic_select(db, all_of(t)).from(t).unconditionally().group_by(t.alpha).dynamic_having(expression)); decltype(dynamic_select(db, all_of(t)).from(t).unconditionally().group_by(t.alpha).dynamic_having(expression));
using ExpectedReturnType = using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, Assert>::value>;
sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, sqlpp::bad_statement>::value>;
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }
@ -140,7 +138,7 @@ namespace
static_assert(ExpectedCheckResult::value, "Unexpected check result"); static_assert(ExpectedCheckResult::value, "Unexpected check result");
using ReturnType = decltype(select(all_of(t)).from(t).dynamic_having()); using ReturnType = decltype(select(all_of(t)).from(t).dynamic_having());
using ExpectedReturnType = std::is_same<ReturnType, sqlpp::bad_statement>; using ExpectedReturnType = std::is_same<ReturnType, sqlpp::assert_where_dynamic_statement_dynamic_t>;
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015-2015, Roland Bock * Copyright (c) 2015-2016, Roland Bock
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
@ -23,9 +23,9 @@
* OF THE POSSIBILITY OF SUCH DAMAGE. * OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <iostream>
#include "MockDb.h" #include "MockDb.h"
#include "Sample.h" #include "Sample.h"
#include <iostream>
#include <sqlpp11/sqlpp11.h> #include <sqlpp11/sqlpp11.h>
namespace namespace
@ -53,8 +53,7 @@ namespace
static_assert(ExpectedCheckResult::value, "Unexpected check result"); static_assert(ExpectedCheckResult::value, "Unexpected check result");
using ReturnType = decltype(insert_into(t).set(assignments...)); using ReturnType = decltype(insert_into(t).set(assignments...));
using ExpectedReturnType = using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, Assert>::value>;
sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, sqlpp::bad_statement>::value>;
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }
@ -69,8 +68,7 @@ namespace
print_type_on_error<CheckResult>(ExpectedCheckResult{}); print_type_on_error<CheckResult>(ExpectedCheckResult{});
using ReturnType = decltype(dynamic_insert_into(db, t).dynamic_set(assignments...)); using ReturnType = decltype(dynamic_insert_into(db, t).dynamic_set(assignments...));
using ExpectedReturnType = using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, Assert>::value>;
sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, sqlpp::bad_statement>::value>;
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
} }
@ -162,7 +160,7 @@ namespace
print_type_on_error<CheckResult>(ExpectedCheckResult{}); print_type_on_error<CheckResult>(ExpectedCheckResult{});
using ReturnType = decltype(insert_into(t).dynamic_set()); using ReturnType = decltype(insert_into(t).dynamic_set());
using ExpectedReturnType = std::is_same<ReturnType, sqlpp::bad_statement>; using ExpectedReturnType = std::is_same<ReturnType, sqlpp::assert_insert_dynamic_set_statement_dynamic_t>;
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
} }

View File

@ -23,9 +23,9 @@
* OF THE POSSIBILITY OF SUCH DAMAGE. * OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <iostream>
#include "MockDb.h" #include "MockDb.h"
#include "Sample.h" #include "Sample.h"
#include <iostream>
#include <sqlpp11/sqlpp11.h> #include <sqlpp11/sqlpp11.h>
namespace namespace
@ -62,12 +62,9 @@ namespace
(Assert::value and sqlpp::is_pre_join_t<JoinType>::value and sqlpp::is_pre_join_t<InnerJoinType>::value and (Assert::value and sqlpp::is_pre_join_t<JoinType>::value and sqlpp::is_pre_join_t<InnerJoinType>::value and
sqlpp::is_pre_join_t<LeftOuterJoinType>::value and sqlpp::is_pre_join_t<RightOuterJoinType>::value and sqlpp::is_pre_join_t<LeftOuterJoinType>::value and sqlpp::is_pre_join_t<RightOuterJoinType>::value and
sqlpp::is_pre_join_t<OuterJoinType>::value and sqlpp::is_join_t<CrossJoinType>::value) xor sqlpp::is_pre_join_t<OuterJoinType>::value and sqlpp::is_join_t<CrossJoinType>::value) xor
(std::is_same<JoinType, sqlpp::bad_statement>::value and (std::is_same<JoinType, Assert>::value and std::is_same<InnerJoinType, Assert>::value and
std::is_same<InnerJoinType, sqlpp::bad_statement>::value and std::is_same<LeftOuterJoinType, Assert>::value and std::is_same<RightOuterJoinType, Assert>::value and
std::is_same<LeftOuterJoinType, sqlpp::bad_statement>::value and std::is_same<OuterJoinType, Assert>::value and std::is_same<CrossJoinType, Assert>::value)>;
std::is_same<RightOuterJoinType, sqlpp::bad_statement>::value and
std::is_same<OuterJoinType, sqlpp::bad_statement>::value and
std::is_same<CrossJoinType, sqlpp::bad_statement>::value)>;
print_type_on_error<JoinType>(ExpectedReturnType{}); print_type_on_error<JoinType>(ExpectedReturnType{});
print_type_on_error<InnerJoinType>(ExpectedReturnType{}); print_type_on_error<InnerJoinType>(ExpectedReturnType{});
print_type_on_error<LeftOuterJoinType>(ExpectedReturnType{}); print_type_on_error<LeftOuterJoinType>(ExpectedReturnType{});
@ -87,7 +84,7 @@ namespace
using ResultType = decltype(lhs.on(rhs)); using ResultType = decltype(lhs.on(rhs));
using ExpectedReturnType = sqlpp::logic::all_t<(Assert::value and sqlpp::is_join_t<ResultType>::value) xor using ExpectedReturnType = sqlpp::logic::all_t<(Assert::value and sqlpp::is_join_t<ResultType>::value) xor
std::is_same<ResultType, sqlpp::bad_statement>::value>; std::is_same<ResultType, Assert>::value>;
print_type_on_error<ResultType>(ExpectedReturnType{}); print_type_on_error<ResultType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }
@ -190,18 +187,15 @@ namespace
using RightOuterJoinType = decltype(sqlpp::dynamic_right_outer_join(table)); using RightOuterJoinType = decltype(sqlpp::dynamic_right_outer_join(table));
using OuterJoinType = decltype(sqlpp::dynamic_outer_join(table)); using OuterJoinType = decltype(sqlpp::dynamic_outer_join(table));
using CrossJoinType = decltype(sqlpp::dynamic_cross_join(table)); using CrossJoinType = decltype(sqlpp::dynamic_cross_join(table));
using ExpectedReturnType = sqlpp::logic::all_t<(Assert::value and sqlpp::is_dynamic_pre_join_t<JoinType>::value and using ExpectedReturnType = sqlpp::logic::all_t<
sqlpp::is_dynamic_pre_join_t<InnerJoinType>::value and (Assert::value and sqlpp::is_dynamic_pre_join_t<JoinType>::value and
sqlpp::is_dynamic_pre_join_t<LeftOuterJoinType>::value and sqlpp::is_dynamic_pre_join_t<InnerJoinType>::value and
sqlpp::is_dynamic_pre_join_t<RightOuterJoinType>::value and sqlpp::is_dynamic_pre_join_t<LeftOuterJoinType>::value and
sqlpp::is_dynamic_pre_join_t<OuterJoinType>::value and sqlpp::is_dynamic_pre_join_t<RightOuterJoinType>::value and
sqlpp::is_dynamic_join_t<CrossJoinType>::value) xor sqlpp::is_dynamic_pre_join_t<OuterJoinType>::value and sqlpp::is_dynamic_join_t<CrossJoinType>::value) xor
(std::is_same<JoinType, sqlpp::bad_statement>::value and (std::is_same<JoinType, Assert>::value and std::is_same<InnerJoinType, Assert>::value and
std::is_same<InnerJoinType, sqlpp::bad_statement>::value and std::is_same<LeftOuterJoinType, Assert>::value and std::is_same<RightOuterJoinType, Assert>::value and
std::is_same<LeftOuterJoinType, sqlpp::bad_statement>::value and std::is_same<OuterJoinType, Assert>::value and std::is_same<CrossJoinType, Assert>::value)>;
std::is_same<RightOuterJoinType, sqlpp::bad_statement>::value and
std::is_same<OuterJoinType, sqlpp::bad_statement>::value and
std::is_same<CrossJoinType, sqlpp::bad_statement>::value)>;
print_type_on_error<JoinType>(ExpectedReturnType{}); print_type_on_error<JoinType>(ExpectedReturnType{});
print_type_on_error<InnerJoinType>(ExpectedReturnType{}); print_type_on_error<InnerJoinType>(ExpectedReturnType{});
print_type_on_error<LeftOuterJoinType>(ExpectedReturnType{}); print_type_on_error<LeftOuterJoinType>(ExpectedReturnType{});
@ -221,7 +215,7 @@ namespace
using ResultType = decltype(lhs.on(rhs)); using ResultType = decltype(lhs.on(rhs));
using ExpectedReturnType = sqlpp::logic::all_t<(Assert::value and sqlpp::is_dynamic_join_t<ResultType>::value) xor using ExpectedReturnType = sqlpp::logic::all_t<(Assert::value and sqlpp::is_dynamic_join_t<ResultType>::value) xor
std::is_same<ResultType, sqlpp::bad_statement>::value>; std::is_same<ResultType, Assert>::value>;
print_type_on_error<ResultType>(ExpectedReturnType{}); print_type_on_error<ResultType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }

View File

@ -23,9 +23,9 @@
* OF THE POSSIBILITY OF SUCH DAMAGE. * OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <iostream>
#include "MockDb.h" #include "MockDb.h"
#include "Sample.h" #include "Sample.h"
#include <iostream>
#include <sqlpp11/sqlpp11.h> #include <sqlpp11/sqlpp11.h>
namespace namespace
@ -82,8 +82,7 @@ namespace
void where_check(const Condition& condition) void where_check(const Condition& condition)
{ {
using ReturnType = decltype(sqlpp::where(condition)); using ReturnType = decltype(sqlpp::where(condition));
using ExpectedReturnType = using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, Assert>::value>;
sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, sqlpp::bad_statement>::value>;
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }
@ -104,7 +103,7 @@ namespace
void where() void where()
{ {
where_check<sqlpp::consistent_t>(t.gamma); where_check<sqlpp::consistent_t>(t.gamma);
where_check<sqlpp::bad_statement>(true); where_check<sqlpp::assert_where_not_cpp_bool_t>(true);
} }
} }

View File

@ -23,9 +23,9 @@
* OF THE POSSIBILITY OF SUCH DAMAGE. * OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <iostream>
#include "MockDb.h" #include "MockDb.h"
#include "Sample.h" #include "Sample.h"
#include <iostream>
#include <sqlpp11/sqlpp11.h> #include <sqlpp11/sqlpp11.h>
namespace namespace
@ -53,8 +53,7 @@ namespace
static_assert(ExpectedCheckResult::value, "Unexpected check result"); static_assert(ExpectedCheckResult::value, "Unexpected check result");
using ReturnType = decltype(update(t).set(expressions...)); using ReturnType = decltype(update(t).set(expressions...));
using ExpectedReturnType = using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, Assert>::value>;
sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, sqlpp::bad_statement>::value>;
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }
@ -69,8 +68,7 @@ namespace
static_assert(ExpectedCheckResult::value, "Unexpected check result"); static_assert(ExpectedCheckResult::value, "Unexpected check result");
using ReturnType = decltype(dynamic_update(db, t).dynamic_set(expressions...)); using ReturnType = decltype(dynamic_update(db, t).dynamic_set(expressions...));
using ExpectedReturnType = using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, Assert>::value>;
sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, sqlpp::bad_statement>::value>;
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }
@ -127,7 +125,7 @@ namespace
static_assert(ExpectedCheckResult::value, "Unexpected check result"); static_assert(ExpectedCheckResult::value, "Unexpected check result");
using ReturnType = decltype(update(t).dynamic_set()); using ReturnType = decltype(update(t).dynamic_set());
using ExpectedReturnType = std::is_same<ReturnType, sqlpp::bad_statement>; using ExpectedReturnType = std::is_same<ReturnType, sqlpp::assert_update_dynamic_set_statement_dynamic_t>;
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }

View File

@ -23,9 +23,9 @@
* OF THE POSSIBILITY OF SUCH DAMAGE. * OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <iostream>
#include "MockDb.h" #include "MockDb.h"
#include "Sample.h" #include "Sample.h"
#include <iostream>
#include <sqlpp11/sqlpp11.h> #include <sqlpp11/sqlpp11.h>
namespace namespace
@ -52,8 +52,7 @@ namespace
static_assert(ExpectedCheckResult::value, "Unexpected check result"); static_assert(ExpectedCheckResult::value, "Unexpected check result");
using ReturnType = decltype(remove_from(t).where(expression)); using ReturnType = decltype(remove_from(t).where(expression));
using ExpectedReturnType = using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, Assert>::value>;
sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, sqlpp::bad_statement>::value>;
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }
@ -68,8 +67,7 @@ namespace
static_assert(ExpectedCheckResult::value, "Unexpected check result"); static_assert(ExpectedCheckResult::value, "Unexpected check result");
using ReturnType = decltype(dynamic_remove_from(db, t).dynamic_where(expression)); using ReturnType = decltype(dynamic_remove_from(db, t).dynamic_where(expression));
using ExpectedReturnType = using ExpectedReturnType = sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, Assert>::value>;
sqlpp::logic::all_t<Assert::value xor std::is_same<ReturnType, sqlpp::bad_statement>::value>;
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }
@ -140,7 +138,7 @@ namespace
static_assert(ExpectedCheckResult::value, "Unexpected check result"); static_assert(ExpectedCheckResult::value, "Unexpected check result");
using ReturnType = decltype(remove_from(t).dynamic_where()); using ReturnType = decltype(remove_from(t).dynamic_where());
using ExpectedReturnType = std::is_same<ReturnType, sqlpp::bad_statement>; using ExpectedReturnType = std::is_same<ReturnType, sqlpp::assert_where_dynamic_statement_dynamic_t>;
print_type_on_error<ReturnType>(ExpectedReturnType{}); print_type_on_error<ReturnType>(ExpectedReturnType{});
static_assert(ExpectedReturnType::value, "Unexpected return type"); static_assert(ExpectedReturnType::value, "Unexpected return type");
} }

View File

@ -36,14 +36,14 @@ set(test_names
#Interpret #Interpret
#Insert #Insert
#Remove #Remove
Update #Update
#Select #Select
#SelectType #SelectType
#Function #Function
#Prepared #Prepared
#Minimalistic #Minimalistic
#Result #Result
#Union Union
#With #With
) )