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

Disabled select(tab). Use select(all_of(tab)) instead.

This commit is contained in:
Roland Bock 2013-10-03 21:36:50 +02:00
parent 96c6e5d435
commit 4d8e448152
2 changed files with 16 additions and 9 deletions

View File

@ -32,31 +32,38 @@ namespace sqlpp
namespace detail namespace detail
{ {
template<typename Expr> 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<typename std::decay<Expr>::type>::value, decltype(std::make_tuple(expr))>::type
{ {
return std::make_tuple(std::forward<Expr>(expr)); return std::make_tuple(std::forward<Expr>(expr));
}; };
template<typename 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<typename std::decay<Expr>::type>::value, std::tuple<>>::type
{ {
return {}; return {};
}; };
/*
template<typename Tab> 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 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 {}; return {};
}; };
*/
template<typename... Expr> template<typename... Expr>
auto make_single_expression_tuple(std::tuple<Expr...>&& t) -> std::tuple<Expr...> auto make_single_expression_tuple(std::tuple<Expr...>&& t)
-> std::tuple<Expr...>
{ {
return t; return t;
}; };
template<typename... Expr> 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(std::forward<Expr>(expr))...))
{ {
return std::tuple_cat(make_single_expression_tuple(std::forward<Expr>(expr))...); return std::tuple_cat(make_single_expression_tuple(std::forward<Expr>(expr))...);
}; };

View File

@ -224,9 +224,9 @@ int main()
{ {
auto a = select(all_of(t)); auto a = select(all_of(t));
auto b = select(t.alpha, t.beta, t.gamma); auto b = select(t.alpha, t.beta, t.gamma);
auto c = select(t); //auto c = select(t);
static_assert(std::is_same<decltype(a), decltype(b)>::value, "all_of(t) has to be expanded by select()"); static_assert(std::is_same<decltype(a), decltype(b)>::value, "all_of(t) has to be expanded by select()");
static_assert(std::is_same<decltype(b), decltype(c)>::value, "t has to be expanded by select()"); //static_assert(std::is_same<decltype(b), decltype(c)>::value, "t has to be expanded by select()");
} }
// Test that select(all_of(tab)) is expanded in multi_column // Test that select(all_of(tab)) is expanded in multi_column
@ -238,7 +238,7 @@ int main()
// Test that select(tab) is expanded in multi_column // Test that select(tab) is expanded in multi_column
{ {
auto a = multi_column(sqlpp::alias::a, t); auto a = multi_column(sqlpp::alias::a, all_of(t));
auto b = multi_column(sqlpp::alias::a, t.alpha, t.beta, t.gamma); auto b = multi_column(sqlpp::alias::a, t.alpha, t.beta, t.gamma);
static_assert(std::is_same<decltype(a), decltype(b)>::value, "t has to be expanded by multi_column"); static_assert(std::is_same<decltype(a), decltype(b)>::value, "t has to be expanded by multi_column");
} }
@ -263,7 +263,7 @@ int main()
} }
{ {
auto s = dynamic_select(db, t).dynamic_from().dynamic_where().dynamic_limit().dynamic_offset(); auto s = dynamic_select(db, all_of(t)).dynamic_from().dynamic_where().dynamic_limit().dynamic_offset();
s = s.add_from(t); s = s.add_from(t);
s = s.add_where(t.alpha > 7); s = s.add_where(t.alpha > 7);
s = s.set_limit(30); s = s.set_limit(30);