mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Added missing .unconditionally() member functions for joins
This commit is contained in:
parent
6bdddcc343
commit
3d67da2373
@ -88,6 +88,11 @@ namespace sqlpp
|
|||||||
static_assert(required_tables_of<dynamic_pre_join_t>::size::value == 0,
|
static_assert(required_tables_of<dynamic_pre_join_t>::size::value == 0,
|
||||||
"joined tables must not depend on other tables");
|
"joined tables must not depend on other tables");
|
||||||
|
|
||||||
|
auto unconditionally() const -> dynamic_join_t<dynamic_pre_join_t, on_t<unconditional_t>>
|
||||||
|
{
|
||||||
|
return {*this, {}};
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Expr>
|
template <typename Expr>
|
||||||
auto on(Expr expr) const -> typename std::conditional<check_dynamic_join_on_t<dynamic_pre_join_t, Expr>::value,
|
auto on(Expr expr) const -> typename std::conditional<check_dynamic_join_on_t<dynamic_pre_join_t, Expr>::value,
|
||||||
dynamic_join_t<dynamic_pre_join_t, on_t<Expr>>,
|
dynamic_join_t<dynamic_pre_join_t, on_t<Expr>>,
|
||||||
|
@ -102,6 +102,11 @@ namespace sqlpp
|
|||||||
|
|
||||||
static_assert(required_tables_of<pre_join_t>::size::value == 0, "joined tables must not depend on other tables");
|
static_assert(required_tables_of<pre_join_t>::size::value == 0, "joined tables must not depend on other tables");
|
||||||
|
|
||||||
|
auto unconditionally() -> join_t<pre_join_t, on_t<unconditional_t>>
|
||||||
|
{
|
||||||
|
return {*this, {}};
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Expr>
|
template <typename Expr>
|
||||||
auto on(Expr expr) const -> typename std::conditional<check_join_on_t<pre_join_t, Expr>::value,
|
auto on(Expr expr) const -> typename std::conditional<check_join_on_t<pre_join_t, Expr>::value,
|
||||||
join_t<pre_join_t, on_t<Expr>>,
|
join_t<pre_join_t, on_t<Expr>>,
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "compare.h"
|
|
||||||
#include "Sample.h"
|
#include "Sample.h"
|
||||||
|
#include "compare.h"
|
||||||
#include <sqlpp11/sqlpp11.h>
|
#include <sqlpp11/sqlpp11.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@ -61,6 +61,7 @@ int From(int, char* [])
|
|||||||
compare(
|
compare(
|
||||||
__LINE__, from(aFoo.join(bFoo).on(aFoo.omega > bFoo.omega).join(cFoo).on(bFoo.omega > cFoo.omega)),
|
__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)");
|
" 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
|
// Static joins involving verbatim tables
|
||||||
compare(__LINE__, from(aFoo.join(sqlpp::verbatim_table("unknown_table"))
|
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));
|
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)");
|
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;
|
auto dfa = df;
|
||||||
dfa.from.add(dynamic_inner_join(bar).on(bar.alpha > foo.omega));
|
dfa.from.add(dynamic_inner_join(bar).on(bar.alpha > foo.omega));
|
||||||
|
Loading…
Reference in New Issue
Block a user