diff --git a/include/sqlpp11/dynamic_pre_join.h b/include/sqlpp11/dynamic_pre_join.h index da698e6c..ed3dab9a 100644 --- a/include/sqlpp11/dynamic_pre_join.h +++ b/include/sqlpp11/dynamic_pre_join.h @@ -88,6 +88,11 @@ namespace sqlpp static_assert(required_tables_of::size::value == 0, "joined tables must not depend on other tables"); + auto unconditionally() const -> dynamic_join_t> + { + return {*this, {}}; + } + template auto on(Expr expr) const -> typename std::conditional::value, dynamic_join_t>, diff --git a/include/sqlpp11/pre_join.h b/include/sqlpp11/pre_join.h index 7cd8a9dc..d8ef6d69 100644 --- a/include/sqlpp11/pre_join.h +++ b/include/sqlpp11/pre_join.h @@ -102,6 +102,11 @@ namespace sqlpp static_assert(required_tables_of::size::value == 0, "joined tables must not depend on other tables"); + auto unconditionally() -> join_t> + { + return {*this, {}}; + } + template auto on(Expr expr) const -> typename std::conditional::value, join_t>, diff --git a/test_serializer/From.cpp b/test_serializer/From.cpp index f5d472ff..7ea8126f 100644 --- a/test_serializer/From.cpp +++ b/test_serializer/From.cpp @@ -23,8 +23,8 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "compare.h" #include "Sample.h" +#include "compare.h" #include namespace @@ -61,6 +61,7 @@ int From(int, char* []) compare( __LINE__, from(aFoo.join(bFoo).on(aFoo.omega > bFoo.omega).join(cFoo).on(bFoo.omega > cFoo.omega)), " FROM tab_foo AS a INNER JOIN tab_foo AS b ON (a.omega>b.omega) INNER JOIN tab_foo AS c ON (b.omega>c.omega)"); + compare(__LINE__, from(foo.join(bar).unconditionally()), " FROM tab_foo INNER JOIN tab_bar"); // Static joins involving verbatim tables compare(__LINE__, from(aFoo.join(sqlpp::verbatim_table("unknown_table")) @@ -109,6 +110,11 @@ int From(int, char* []) dfa.from.add(dynamic_right_outer_join(bar).on(bar.alpha > foo.omega)); compare(__LINE__, dfa, " FROM tab_foo RIGHT OUTER JOIN tab_bar ON (tab_bar.alpha>tab_foo.omega)"); } + { + auto dfa = df; + dfa.from.add(dynamic_join(bar).unconditionally()); + compare(__LINE__, dfa, " FROM tab_foo INNER JOIN tab_bar"); + } { auto dfa = df; dfa.from.add(dynamic_inner_join(bar).on(bar.alpha > foo.omega));