diff --git a/include/sqlpp11/dynamic_join.h b/include/sqlpp11/dynamic_join.h index 90cb3045..5aa9b7a1 100644 --- a/include/sqlpp11/dynamic_join.h +++ b/include/sqlpp11/dynamic_join.h @@ -27,36 +27,36 @@ #ifndef SQLPP_DYNAMIC_JOIN_H #define SQLPP_DYNAMIC_JOIN_H -#include +#include namespace sqlpp { - template + template struct dynamic_join_t { using _traits = make_traits; - using _nodes = detail::type_vector; + using _nodes = detail::type_vector; using _can_be_null = std::false_type; - using _provided_tables = provided_tables_of; + using _provided_tables = provided_tables_of; using _required_tables = detail::type_set<>; - static_assert(is_dynamic_cross_join_t::value, "lhs argument for on() has to be a cross join"); - static_assert(required_tables_of::size::value == 0, "joined tables must not depend on other tables"); + static_assert(is_dynamic_pre_join_t::value, "lhs argument for on() has to be a pre join"); + static_assert(required_tables_of::size::value == 0, "joined tables must not depend on other tables"); static_assert(is_on_t::value, "invalid on expression in join().on()"); - CrossJoin _cross_join; + PreJoin _pre_join; On _on; }; - template - struct serializer_t> + template + struct serializer_t> { - using _serialize_check = serialize_check_of; - using T = dynamic_join_t; + using _serialize_check = serialize_check_of; + using T = dynamic_join_t; static Context& _(const T& t, Context& context) { - serialize(t._cross_join, context); + serialize(t._pre_join, context); serialize(t._on, context); return context; } diff --git a/include/sqlpp11/dynamic_cross_join.h b/include/sqlpp11/dynamic_pre_join.h similarity index 54% rename from include/sqlpp11/dynamic_cross_join.h rename to include/sqlpp11/dynamic_pre_join.h index 2795417c..be2472df 100644 --- a/include/sqlpp11/dynamic_cross_join.h +++ b/include/sqlpp11/dynamic_pre_join.h @@ -24,93 +24,88 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SQLPP_DYNAMIC_CROSS_JOIN_H -#define SQLPP_DYNAMIC_CROSS_JOIN_H +#ifndef SQLPP_DYNAMIC_PRE_JOIN_H +#define SQLPP_DYNAMIC_PRE_JOIN_H #include #include namespace sqlpp { - SQLPP_PORTABLE_STATIC_ASSERT(assert_dynamic_cross_join_table_t, "argument of dynamic_join() has to be a table"); - SQLPP_PORTABLE_STATIC_ASSERT(assert_dynamic_cross_join_no_join_t, "argument of dynamic_join() must not be a table"); + SQLPP_PORTABLE_STATIC_ASSERT(assert_dynamic_pre_join_table_t, "argument of dynamic_join() has to be a table"); + SQLPP_PORTABLE_STATIC_ASSERT(assert_dynamic_pre_join_no_join_t, "argument of dynamic_join() must not be a table"); template - struct check_dynamic_cross_join + struct check_dynamic_pre_join { using type = - static_combined_check_t::value, assert_dynamic_cross_join_table_t>, - static_check_t::value, assert_dynamic_cross_join_no_join_t>>; + static_combined_check_t::value, assert_dynamic_pre_join_table_t>, + static_check_t::value, assert_dynamic_pre_join_no_join_t>>; }; template - using check_dynamic_cross_join_t = typename check_dynamic_cross_join::type; + using check_dynamic_pre_join_t = typename check_dynamic_pre_join
::type; - SQLPP_PORTABLE_STATIC_ASSERT(assert_dynamic_join_consist_of_cross_join_and_on_t, - "dynamic join has to consist of a dynamic cross_join and a join condition"); + SQLPP_PORTABLE_STATIC_ASSERT(assert_dynamic_join_consist_of_pre_join_and_on_t, + "dynamic join has to consist of a dynamic pre_join and a join condition"); SQLPP_PORTABLE_STATIC_ASSERT(assert_dynamic_join_no_table_dependencies_t, "dynamically joined tables must not depend on other tables"); - template + template struct check_dynamic_join { using type = static_combined_check_t< - static_check_t::value, assert_dynamic_join_consist_of_cross_join_and_on_t>, - static_check_t::value, assert_dynamic_join_consist_of_cross_join_and_on_t>, - static_check_t::size::value == 0, assert_dynamic_join_no_table_dependencies_t>>; + static_check_t::value, assert_dynamic_join_consist_of_pre_join_and_on_t>, + static_check_t::value, assert_dynamic_join_consist_of_pre_join_and_on_t>, + static_check_t::size::value == 0, assert_dynamic_join_no_table_dependencies_t>>; }; - template - using check_dynamic_join_t = typename check_dynamic_join::type; + template + using check_dynamic_join_t = typename check_dynamic_join::type; - template + template struct check_dynamic_join_on { - using type = static_combined_check_t, check_dynamic_join_t>>; + using type = static_combined_check_t, check_dynamic_join_t>>; }; - template - using check_dynamic_join_on_t = typename check_dynamic_join_on::type; + template + using check_dynamic_join_on_t = typename check_dynamic_join_on::type; - template + template struct dynamic_join_t; template - struct dynamic_cross_join_t + struct dynamic_pre_join_t { - using _traits = make_traits; + using _traits = make_traits; using _nodes = detail::type_vector; using _can_be_null = std::false_type; static_assert(is_table_t::value, "rhs argument for dynamic_join() has to be a table"); static_assert(not is_join_t::value, "rhs argument for dynamic_join must not be a join"); - static_assert(required_tables_of::size::value == 0, + static_assert(required_tables_of::size::value == 0, "joined tables must not depend on other tables"); template - auto on(Expr expr) const -> typename std::conditional::value, - dynamic_join_t>, + auto on(Expr expr) const -> typename std::conditional::value, + dynamic_join_t>, bad_statement>::type { - check_dynamic_join_on_t::_(); + check_dynamic_join_on_t::_(); return {*this, {expr}}; } - auto unconditionally() -> dynamic_join_t> - { - return {*this, {}}; - } - Rhs _rhs; }; template - struct serializer_t> + struct serializer_t> { using _serialize_check = serialize_check_of; - using T = dynamic_cross_join_t; + using T = dynamic_pre_join_t; static Context& _(const T& t, Context& context) { @@ -121,44 +116,54 @@ namespace sqlpp }; template - using make_dynamic_cross_join_t = typename std::conditional::value, - dynamic_cross_join_t, - bad_statement>::type; + using make_dynamic_pre_join_t = typename std::conditional::value, + dynamic_pre_join_t, + bad_statement>::type; template - auto dynamic_join(Table table) -> make_dynamic_cross_join_t + auto dynamic_join(Table table) -> make_dynamic_pre_join_t { - check_dynamic_cross_join_t
::_(); + check_dynamic_pre_join_t
::_(); return {table}; } template - auto dynamic_inner_join(Table table) -> make_dynamic_cross_join_t + auto dynamic_inner_join(Table table) -> make_dynamic_pre_join_t { - check_dynamic_cross_join_t
::_(); + check_dynamic_pre_join_t
::_(); return {table}; } template - auto dynamic_left_outer_join(Table table) -> make_dynamic_cross_join_t + auto dynamic_left_outer_join(Table table) -> make_dynamic_pre_join_t { - check_dynamic_cross_join_t
::_(); + check_dynamic_pre_join_t
::_(); return {table}; } template - auto dynamic_right_outer_join(Table table) -> make_dynamic_cross_join_t + auto dynamic_right_outer_join(Table table) -> make_dynamic_pre_join_t { - check_dynamic_cross_join_t
::_(); + check_dynamic_pre_join_t
::_(); return {table}; } template - auto dynamic_outer_join(Table table) -> make_dynamic_cross_join_t + auto dynamic_outer_join(Table table) -> make_dynamic_pre_join_t { - check_dynamic_cross_join_t
::_(); + check_dynamic_pre_join_t
::_(); return {table}; } + + template + auto dynamic_cross_join(Table table) -> + typename std::conditional::value, + dynamic_join_t, on_t>, + bad_statement>::type + { + check_dynamic_pre_join_t
::_(); + return {dynamic_pre_join_t{table}, {}}; + } } #endif diff --git a/include/sqlpp11/from.h b/include/sqlpp11/from.h index 83b906fe..74dc84e6 100644 --- a/include/sqlpp11/from.h +++ b/include/sqlpp11/from.h @@ -148,8 +148,8 @@ namespace sqlpp }; SQLPP_PORTABLE_STATIC_ASSERT( - assert_from_not_cross_join_t, - "from() argument is a cross join, please use an explicit on() condition or unconditionally()"); + assert_from_not_pre_join_t, + "from() argument is a pre join, please use an explicit on() condition or unconditionally()"); SQLPP_PORTABLE_STATIC_ASSERT(assert_from_table_t, "from() argument has to be a table or join expression"); SQLPP_PORTABLE_STATIC_ASSERT(assert_from_dependency_free_t, "at least one table depends on another table in from()"); SQLPP_PORTABLE_STATIC_ASSERT(assert_from_no_duplicates_t, "at least one duplicate table name detected in from()"); @@ -161,7 +161,7 @@ namespace sqlpp struct check_from { using type = static_combined_check_t< - static_check_t::value, assert_from_not_cross_join_t>, + static_check_t::value, assert_from_not_pre_join_t>, static_check_t::value, assert_from_table_t>, static_check_t::size::value == 0, assert_from_dependency_free_t>, static_check_t::size::value == diff --git a/include/sqlpp11/join.h b/include/sqlpp11/join.h index 8679cf02..09ecb8fa 100644 --- a/include/sqlpp11/join.h +++ b/include/sqlpp11/join.h @@ -28,18 +28,18 @@ #define SQLPP_JOIN_H #include -#include +#include #include namespace sqlpp { - template + template struct join_t { using _traits = make_traits; - using _nodes = detail::type_vector; + using _nodes = detail::type_vector; using _can_be_null = std::false_type; - using _provided_tables = provided_tables_of; + using _provided_tables = provided_tables_of; using _required_tables = detail::make_difference_set_t, _provided_tables>; template @@ -72,19 +72,25 @@ namespace sqlpp return ::sqlpp::outer_join(*this, t); } - CrossJoin _cross_join; + template + auto cross_join(T t) const -> decltype(::sqlpp::cross_join(*this, t)) + { + return ::sqlpp::cross_join(*this, t); + } + + PreJoin _pre_join; On _on; }; - template - struct serializer_t> + template + struct serializer_t> { - using _serialize_check = serialize_check_of; - using T = join_t; + using _serialize_check = serialize_check_of; + using T = join_t; static Context& _(const T& t, Context& context) { - serialize(t._cross_join, context); + serialize(t._pre_join, context); serialize(t._on, context); return context; } diff --git a/include/sqlpp11/join_types.h b/include/sqlpp11/join_types.h index 1f670b7c..a58a127f 100644 --- a/include/sqlpp11/join_types.h +++ b/include/sqlpp11/join_types.h @@ -60,6 +60,14 @@ namespace sqlpp static constexpr const char* _name = " RIGHT OUTER "; }; + struct cross_join_t + { + template + using _provided_outer_tables = + detail::make_joined_set_t, provided_outer_tables_of>; + + static constexpr const char* _name = " CROSS "; + }; } #endif diff --git a/include/sqlpp11/cross_join.h b/include/sqlpp11/pre_join.h similarity index 62% rename from include/sqlpp11/cross_join.h rename to include/sqlpp11/pre_join.h index 3510cb0a..38571276 100644 --- a/include/sqlpp11/cross_join.h +++ b/include/sqlpp11/pre_join.h @@ -24,8 +24,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SQLPP_CROSS_JOIN_H -#define SQLPP_CROSS_JOIN_H +#ifndef SQLPP_PRE_JOIN_H +#define SQLPP_PRE_JOIN_H #include #include @@ -33,62 +33,62 @@ namespace sqlpp { - SQLPP_PORTABLE_STATIC_ASSERT(assert_cross_join_lhs_table_t, "lhs argument of join() has to be a table or a join"); - SQLPP_PORTABLE_STATIC_ASSERT(assert_cross_join_rhs_table_t, "rhs argument of join() has to be a table"); - SQLPP_PORTABLE_STATIC_ASSERT(assert_cross_join_rhs_no_join_t, "rhs argument of join() must not be a join"); - SQLPP_PORTABLE_STATIC_ASSERT(assert_cross_join_unique_names_t, "joined table names have to be unique"); + SQLPP_PORTABLE_STATIC_ASSERT(assert_pre_join_lhs_table_t, "lhs argument of join() has to be a table or a join"); + SQLPP_PORTABLE_STATIC_ASSERT(assert_pre_join_rhs_table_t, "rhs argument of join() has to be a table"); + SQLPP_PORTABLE_STATIC_ASSERT(assert_pre_join_rhs_no_join_t, "rhs argument of join() must not be a join"); + SQLPP_PORTABLE_STATIC_ASSERT(assert_pre_join_unique_names_t, "joined table names have to be unique"); template - struct check_cross_join + struct check_pre_join { using type = static_combined_check_t< - static_check_t::value, assert_cross_join_lhs_table_t>, - static_check_t::value, assert_cross_join_rhs_table_t>, - static_check_t::value, assert_cross_join_rhs_no_join_t>, + static_check_t::value, assert_pre_join_lhs_table_t>, + static_check_t::value, assert_pre_join_rhs_table_t>, + static_check_t::value, assert_pre_join_rhs_no_join_t>, static_check_t>, detail::make_name_of_set_t>>::value, - assert_cross_join_unique_names_t>>; + assert_pre_join_unique_names_t>>; }; template - using check_cross_join_t = typename check_cross_join::type; + using check_pre_join_t = typename check_pre_join::type; - SQLPP_PORTABLE_STATIC_ASSERT(assert_join_consist_of_cross_join_and_on_t, - "join has to consist of a cross_join and a join condition"); + SQLPP_PORTABLE_STATIC_ASSERT(assert_join_consist_of_pre_join_and_on_t, + "join has to consist of a pre_join and a join condition"); SQLPP_PORTABLE_STATIC_ASSERT(assert_join_no_table_dependencies_t, "joined tables must not depend on other tables"); SQLPP_PORTABLE_STATIC_ASSERT(assert_join_on_no_foreign_table_dependencies_t, "on() condition must not depend on other tables"); - template + template struct check_join { using type = static_combined_check_t< - static_check_t::value, assert_join_consist_of_cross_join_and_on_t>, - static_check_t::value, assert_join_consist_of_cross_join_and_on_t>, - static_check_t::size::value == 0, assert_join_no_table_dependencies_t>, - static_check_t, provided_tables_of>::value, + static_check_t::value, assert_join_consist_of_pre_join_and_on_t>, + static_check_t::value, assert_join_consist_of_pre_join_and_on_t>, + static_check_t::size::value == 0, assert_join_no_table_dependencies_t>, + static_check_t, provided_tables_of>::value, assert_join_on_no_foreign_table_dependencies_t>>; }; - template - using check_join_t = typename check_join::type; + template + using check_join_t = typename check_join::type; - template + template struct check_join_on { - using type = static_combined_check_t, check_join_t>>; + using type = static_combined_check_t, check_join_t>>; }; - template - using check_join_on_t = typename check_join_on::type; + template + using check_join_on_t = typename check_join_on::type; - template + template struct join_t; template - struct cross_join_t + struct pre_join_t { - using _traits = make_traits; + using _traits = make_traits; using _nodes = detail::type_vector; using _can_be_null = std::false_type; @@ -99,32 +99,27 @@ namespace sqlpp static_assert(detail::is_disjunct_from, provided_tables_of>::value, "joined tables must not be identical"); - static_assert(required_tables_of::size::value == 0, "joined tables must not depend on other tables"); + static_assert(required_tables_of::size::value == 0, "joined tables must not depend on other tables"); template - auto on(Expr expr) const -> typename std::conditional::value, - join_t>, + auto on(Expr expr) const -> typename std::conditional::value, + join_t>, bad_statement>::type { - check_join_on_t::_(); + check_join_on_t::_(); return {*this, {expr}}; } - auto unconditionally() -> join_t> - { - return {*this, {}}; - } - Lhs _lhs; Rhs _rhs; }; template - struct serializer_t> + struct serializer_t> { using _serialize_check = serialize_check_of; - using T = cross_join_t; + using T = pre_join_t; static Context& _(const T& t, Context& context) { @@ -137,54 +132,65 @@ namespace sqlpp }; template - auto join(Lhs lhs, Rhs rhs) -> typename std::conditional::value, - cross_join_t, + auto join(Lhs lhs, Rhs rhs) -> typename std::conditional::value, + pre_join_t, bad_statement>::type { - check_cross_join_t::_(); + check_pre_join_t::_(); return {lhs, rhs}; } template - auto inner_join(Lhs lhs, Rhs rhs) -> typename std::conditional::value, - cross_join_t, + auto inner_join(Lhs lhs, Rhs rhs) -> typename std::conditional::value, + pre_join_t, bad_statement>::type { - check_cross_join_t::_(); + check_pre_join_t::_(); return {lhs, rhs}; } template - auto left_outer_join(Lhs lhs, Rhs rhs) -> typename std::conditional::value, - cross_join_t, + auto left_outer_join(Lhs lhs, Rhs rhs) -> typename std::conditional::value, + pre_join_t, bad_statement>::type { - check_cross_join_t::_(); + check_pre_join_t::_(); return {lhs, rhs}; } template - auto right_outer_join(Lhs lhs, Rhs rhs) -> typename std::conditional::value, - cross_join_t, + auto right_outer_join(Lhs lhs, Rhs rhs) -> typename std::conditional::value, + pre_join_t, bad_statement>::type { - check_cross_join_t::_(); + check_pre_join_t::_(); return {lhs, rhs}; } template - auto outer_join(Lhs lhs, Rhs rhs) -> typename std::conditional::value, - cross_join_t, + auto outer_join(Lhs lhs, Rhs rhs) -> typename std::conditional::value, + pre_join_t, bad_statement>::type { - check_cross_join_t::_(); + check_pre_join_t::_(); return {lhs, rhs}; } + + template + auto cross_join(Lhs lhs, Rhs rhs) -> + typename std::conditional::value, + join_t, on_t>, + bad_statement>::type + { + check_pre_join_t::_(); + + return {pre_join_t{lhs, rhs}, {}}; + } } #endif diff --git a/include/sqlpp11/table.h b/include/sqlpp11/table.h index 61574e02..7e51f22d 100644 --- a/include/sqlpp11/table.h +++ b/include/sqlpp11/table.h @@ -97,6 +97,12 @@ namespace sqlpp return {*static_cast(this)}; } + template + auto cross_join(T t) const -> decltype(::sqlpp::cross_join(std::declval
(), t)) + { + return ::sqlpp::cross_join(*static_cast(this), t); + } + const Table& ref() const { return *static_cast(this); diff --git a/include/sqlpp11/table_alias.h b/include/sqlpp11/table_alias.h index 06ffe23d..52e04c31 100644 --- a/include/sqlpp11/table_alias.h +++ b/include/sqlpp11/table_alias.h @@ -90,6 +90,12 @@ namespace sqlpp return ::sqlpp::outer_join(*this, t); } + template + auto cross_join(T t) const -> decltype(::sqlpp::cross_join(*this, t)) + { + return ::sqlpp::cross_join(*this, t); + } + Table _table; }; diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index adbf0b99..f97a05d2 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -169,9 +169,9 @@ namespace sqlpp SQLPP_VALUE_TRAIT_GENERATOR(is_return_value) SQLPP_VALUE_TRAIT_GENERATOR(is_table) SQLPP_VALUE_TRAIT_GENERATOR(is_raw_table) - SQLPP_VALUE_TRAIT_GENERATOR(is_cross_join) + SQLPP_VALUE_TRAIT_GENERATOR(is_pre_join) SQLPP_VALUE_TRAIT_GENERATOR(is_join) - SQLPP_VALUE_TRAIT_GENERATOR(is_dynamic_cross_join) + SQLPP_VALUE_TRAIT_GENERATOR(is_dynamic_pre_join) SQLPP_VALUE_TRAIT_GENERATOR(is_dynamic_join) SQLPP_VALUE_TRAIT_GENERATOR(is_pseudo_table) SQLPP_VALUE_TRAIT_GENERATOR(is_column) diff --git a/test_static_asserts/from.cpp b/test_static_asserts/from.cpp index a102e804..fff9d433 100644 --- a/test_static_asserts/from.cpp +++ b/test_static_asserts/from.cpp @@ -79,7 +79,7 @@ namespace { // OK from_static_check(t); - from_static_check(t.join(f).unconditionally()); + from_static_check(t.cross_join(f)); from_static_check(t.join(f).on(t.alpha > f.omega)); // Try a bunch of non-tables @@ -90,14 +90,14 @@ namespace from_static_check(t.delta); // Try cross joins (missing condition) - from_static_check(t.join(f)); + from_static_check(t.join(f)); } void dynamic_from() { // OK from_dynamic_check(t); - from_dynamic_check(t.join(f).unconditionally()); + from_dynamic_check(t.cross_join(f)); from_dynamic_check(t.join(f).on(t.alpha > f.omega)); // Try a bunch of non-tables @@ -108,7 +108,7 @@ namespace from_dynamic_check(t.delta); // Try cross joins (missing condition) - from_dynamic_check(t.join(f)); + from_dynamic_check(t.join(f)); } } diff --git a/test_static_asserts/join.cpp b/test_static_asserts/join.cpp index ebaed7c6..29369ed3 100644 --- a/test_static_asserts/join.cpp +++ b/test_static_asserts/join.cpp @@ -47,7 +47,7 @@ namespace template void join_static_check(const Lhs& lhs, const Rhs& rhs) { - using CheckResult = sqlpp::check_cross_join_t; + using CheckResult = sqlpp::check_pre_join_t; using ExpectedCheckResult = std::is_same; print_type_on_error(ExpectedCheckResult{}); static_assert(ExpectedCheckResult::value, "Unexpected check result"); @@ -57,20 +57,23 @@ namespace using LeftOuterJoinType = decltype(sqlpp::left_outer_join(lhs, rhs)); using RightOuterJoinType = decltype(sqlpp::right_outer_join(lhs, rhs)); using OuterJoinType = decltype(sqlpp::outer_join(lhs, rhs)); + using CrossJoinType = decltype(sqlpp::cross_join(lhs, rhs)); using ExpectedReturnType = sqlpp::logic::all_t< - (Assert::value and sqlpp::is_cross_join_t::value and sqlpp::is_cross_join_t::value and - sqlpp::is_cross_join_t::value and sqlpp::is_cross_join_t::value and - sqlpp::is_cross_join_t::value) xor + (Assert::value and sqlpp::is_pre_join_t::value and sqlpp::is_pre_join_t::value and + sqlpp::is_pre_join_t::value and sqlpp::is_pre_join_t::value and + sqlpp::is_pre_join_t::value and sqlpp::is_join_t::value) xor (std::is_same::value and std::is_same::value and std::is_same::value and std::is_same::value and - std::is_same::value)>; + std::is_same::value and + std::is_same::value)>; print_type_on_error(ExpectedReturnType{}); print_type_on_error(ExpectedReturnType{}); print_type_on_error(ExpectedReturnType{}); print_type_on_error(ExpectedReturnType{}); print_type_on_error(ExpectedReturnType{}); + print_type_on_error(ExpectedReturnType{}); static_assert(ExpectedReturnType::value, "Unexpected return type"); } @@ -108,7 +111,7 @@ namespace join_static_check(ta, t); // Prepare a join for tests: - const auto j = join(ta, tb).unconditionally(); + const auto j = cross_join(ta, tb); // OK: Add a third table join_static_check(j, f); @@ -116,35 +119,35 @@ namespace join_static_check(j, t); // Try a bunch of non-tables - join_static_check(t, 7); - join_static_check(t, t.alpha); - join_static_check(t, t.beta); - join_static_check(t, t.gamma); - join_static_check(t, t.delta); + join_static_check(t, 7); + join_static_check(t, t.alpha); + join_static_check(t, t.beta); + join_static_check(t, t.gamma); + join_static_check(t, t.delta); - join_static_check(7, t); - join_static_check(t.alpha, t); - join_static_check(t.beta, t); - join_static_check(t.gamma, t); - join_static_check(t.delta, t); + join_static_check(7, t); + join_static_check(t.alpha, t); + join_static_check(t.beta, t); + join_static_check(t.gamma, t); + join_static_check(t.delta, t); // Try to join with join (rhs) - join_static_check(t, j); - join_static_check(f, j); - join_static_check(t.as(sqlpp::alias::left), j); + join_static_check(t, j); + join_static_check(f, j); + join_static_check(t.as(sqlpp::alias::left), j); // Try to join identical table names - join_static_check(t, t); - join_static_check(f, f); - join_static_check(t.as(f), f); - join_static_check(t, f.as(t)); - join_static_check(ta, fa); - join_static_check(j, fa); - join_static_check(j, fb); - join_static_check(j, ta); - join_static_check(j, tb); + join_static_check(t, t); + join_static_check(f, f); + join_static_check(t.as(f), f); + join_static_check(t, f.as(t)); + join_static_check(ta, fa); + join_static_check(j, fa); + join_static_check(j, fb); + join_static_check(j, ta); + join_static_check(j, tb); - // Prepare a cross_joins for tests: + // Prepare a pre_joins for tests: const auto t_f = join(t, f); const auto f_t = join(f, t); const auto t_t = join(ta, tb); @@ -176,7 +179,7 @@ namespace template void join_dynamic_check(const Table& table) { - using CheckResult = sqlpp::check_dynamic_cross_join_t
; + using CheckResult = sqlpp::check_dynamic_pre_join_t
; using ExpectedCheckResult = std::is_same; print_type_on_error(ExpectedCheckResult{}); static_assert(ExpectedCheckResult::value, "Unexpected check result"); @@ -186,22 +189,25 @@ namespace using LeftOuterJoinType = decltype(sqlpp::dynamic_left_outer_join(table)); using RightOuterJoinType = decltype(sqlpp::dynamic_right_outer_join(table)); using OuterJoinType = decltype(sqlpp::dynamic_outer_join(table)); - using ExpectedReturnType = - sqlpp::logic::all_t<(Assert::value and sqlpp::is_dynamic_cross_join_t::value and - sqlpp::is_dynamic_cross_join_t::value and - sqlpp::is_dynamic_cross_join_t::value and - sqlpp::is_dynamic_cross_join_t::value and - sqlpp::is_dynamic_cross_join_t::value) xor - (std::is_same::value and - std::is_same::value and - std::is_same::value and - std::is_same::value and - std::is_same::value)>; + using CrossJoinType = decltype(sqlpp::dynamic_cross_join(table)); + using ExpectedReturnType = sqlpp::logic::all_t<(Assert::value and sqlpp::is_dynamic_pre_join_t::value and + sqlpp::is_dynamic_pre_join_t::value and + sqlpp::is_dynamic_pre_join_t::value and + sqlpp::is_dynamic_pre_join_t::value and + sqlpp::is_dynamic_pre_join_t::value and + sqlpp::is_dynamic_join_t::value) xor + (std::is_same::value and + std::is_same::value and + std::is_same::value and + std::is_same::value and + std::is_same::value and + std::is_same::value)>; print_type_on_error(ExpectedReturnType{}); print_type_on_error(ExpectedReturnType{}); print_type_on_error(ExpectedReturnType{}); print_type_on_error(ExpectedReturnType{}); print_type_on_error(ExpectedReturnType{}); + print_type_on_error(ExpectedReturnType{}); static_assert(ExpectedReturnType::value, "Unexpected return type"); } @@ -233,17 +239,17 @@ namespace join_dynamic_check(fa); // Try a bunch of non-tables - join_dynamic_check(7); - join_dynamic_check(t.alpha); - join_dynamic_check(t.beta); - join_dynamic_check(t.gamma); - join_dynamic_check(t.delta); + join_dynamic_check(7); + join_dynamic_check(t.alpha); + join_dynamic_check(t.beta); + join_dynamic_check(t.gamma); + join_dynamic_check(t.delta); - // Try (cross) joins - join_dynamic_check(t.join(f)); - join_dynamic_check(t.join(f).unconditionally()); + // Try (pre) joins + join_dynamic_check(t.join(f)); + join_dynamic_check(t.cross_join(f)); - // Prepare a dynamic_cross_joins for tests: + // Prepare a dynamic_pre_joins for tests: const auto tj = dynamic_join(t); const auto fj = dynamic_join(f); diff --git a/tests/Select.cpp b/tests/Select.cpp index ad85898e..43be425c 100644 --- a/tests/Select.cpp +++ b/tests/Select.cpp @@ -146,7 +146,7 @@ int Select(int, char* []) .dynamic_offset(); s.select_flags.add(sqlpp::distinct); s.selected_columns.add(f.omega); - s.from.add(dynamic_join(f).unconditionally()); + s.from.add(dynamic_cross_join(f)); s.where.add(t.alpha > 7); s.having.add(t.alpha > 7); s.limit.set(3); diff --git a/tests/SelectType.cpp b/tests/SelectType.cpp index 968542df..85978cdd 100644 --- a/tests/SelectType.cpp +++ b/tests/SelectType.cpp @@ -376,7 +376,7 @@ int SelectType(int, char* []) auto s1 = sqlpp::select() .flags(sqlpp::distinct, sqlpp::straight_join) .columns(l.gamma, r.a) - .from(r.join(t).unconditionally().join(l).unconditionally()) + .from(r.cross_join(t).cross_join(l)) .where(t.beta == "hello world" and select(t.gamma).from(t)) // .as(alias::right)) .group_by(l.gamma, r.a) .having(r.a != true)