mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 12:51:13 +08:00
More tests and fixed names for aggregates
This commit is contained in:
parent
fc0632e0b0
commit
40d03f5312
@ -37,7 +37,7 @@ namespace sqlpp
|
||||
{
|
||||
namespace alias
|
||||
{
|
||||
SQLPP_ALIAS_PROVIDER(avg);
|
||||
SQLPP_ALIAS_PROVIDER(_avg);
|
||||
}
|
||||
|
||||
template <typename Flag, typename Expr>
|
||||
@ -68,7 +68,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Flag, typename Expr>
|
||||
struct name_tag_of<avg_t<Flag, Expr>>: public name_tag_of<alias::avg_t>
|
||||
struct name_tag_of<avg_t<Flag, Expr>>: public name_tag_of<alias::_avg_t>
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace sqlpp
|
||||
{
|
||||
namespace alias
|
||||
{
|
||||
SQLPP_ALIAS_PROVIDER(count);
|
||||
SQLPP_ALIAS_PROVIDER(_count);
|
||||
}
|
||||
|
||||
template <typename Flag, typename Expr>
|
||||
@ -68,7 +68,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Flag, typename Expr>
|
||||
struct name_tag_of<count_t<Flag, Expr>>: public name_tag_of<alias::count_t>
|
||||
struct name_tag_of<count_t<Flag, Expr>>: public name_tag_of<alias::_count_t>
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace sqlpp
|
||||
{
|
||||
namespace alias
|
||||
{
|
||||
SQLPP_ALIAS_PROVIDER(max);
|
||||
SQLPP_ALIAS_PROVIDER(_max);
|
||||
}
|
||||
|
||||
template <typename Flag, typename Expr>
|
||||
@ -67,7 +67,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Flag, typename Expr>
|
||||
struct name_tag_of<max_t<Flag, Expr>>: public name_tag_of<alias::max_t>
|
||||
struct name_tag_of<max_t<Flag, Expr>>: public name_tag_of<alias::_max_t>
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace sqlpp
|
||||
{
|
||||
namespace alias
|
||||
{
|
||||
SQLPP_ALIAS_PROVIDER(min);
|
||||
SQLPP_ALIAS_PROVIDER(_min);
|
||||
}
|
||||
|
||||
template <typename Flag, typename Expr>
|
||||
@ -67,7 +67,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Flag, typename Expr>
|
||||
struct name_tag_of<min_t<Flag, Expr>>: public name_tag_of<alias::min_t>
|
||||
struct name_tag_of<min_t<Flag, Expr>>: public name_tag_of<alias::_min_t>
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace sqlpp
|
||||
{
|
||||
namespace alias
|
||||
{
|
||||
SQLPP_ALIAS_PROVIDER(sum);
|
||||
SQLPP_ALIAS_PROVIDER(_sum);
|
||||
}
|
||||
|
||||
template <typename Flag, typename Expr>
|
||||
@ -67,7 +67,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Flag, typename Expr>
|
||||
struct name_tag_of<sum_t<Flag, Expr>>: public name_tag_of<alias::sum_t>
|
||||
struct name_tag_of<sum_t<Flag, Expr>>: public name_tag_of<alias::_sum_t>
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -223,7 +223,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Column>
|
||||
struct name_tag_of<select_column_list_t<Column>> : public name_tag_of<Column>
|
||||
struct name_tag_of<select_column_list_t<Column>> : public select_column_name_tag_of<Column>
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -29,18 +29,51 @@
|
||||
namespace
|
||||
{
|
||||
SQLPP_ALIAS_PROVIDER(cheese);
|
||||
|
||||
template <typename T>
|
||||
struct clause_of;
|
||||
|
||||
template <typename T>
|
||||
struct clause_of<sqlpp::statement_t<T>>
|
||||
{
|
||||
using type = T;
|
||||
};
|
||||
template <typename T>
|
||||
using clause_of_t = typename clause_of<T>::type;
|
||||
}
|
||||
|
||||
void test_select_columns()
|
||||
{
|
||||
auto v = sqlpp::value(17);
|
||||
auto v = sqlpp::value("text");
|
||||
auto col_int = test::TabFoo{}.id;
|
||||
auto col_txt = test::TabFoo{}.textNnD;
|
||||
|
||||
select_columns(col_int);
|
||||
select_columns(dynamic(true, col_int));
|
||||
select_columns(as(declare_group_by_column(v), cheese));
|
||||
select_columns(dynamic(true, declare_group_by_column(v)).as(cheese));
|
||||
// Single column
|
||||
{
|
||||
using T = clause_of_t<decltype(select_columns(col_int))>;
|
||||
static_assert(std::is_same<sqlpp::name_tag_of_t<T>, test::TabFoo_::Id::_sqlpp_name_tag>::value, "");
|
||||
static_assert(std::is_same<sqlpp::value_type_of_t<T>, sqlpp::integral>::value, "");
|
||||
}
|
||||
|
||||
// Single dynamic column
|
||||
{
|
||||
using T = clause_of_t<decltype(select_columns(dynamic(true, col_int)))>;
|
||||
static_assert(std::is_same<sqlpp::name_tag_of_t<T>, test::TabFoo_::Id::_sqlpp_name_tag>::value, "");
|
||||
static_assert(std::is_same<sqlpp::value_type_of_t<T>, sqlpp::optional<sqlpp::integral>>::value, "");
|
||||
}
|
||||
|
||||
// Single declared group by column
|
||||
{
|
||||
using T = clause_of_t<decltype(select_columns(declare_group_by_column(v).as(cheese)))>;
|
||||
static_assert(std::is_same<sqlpp::name_tag_of_t<T>, cheese_t::_sqlpp_name_tag>::value, "");
|
||||
static_assert(std::is_same<sqlpp::value_type_of_t<T>, sqlpp::text>::value, "");
|
||||
}
|
||||
|
||||
// Single dynamic declared group by column
|
||||
{
|
||||
using T = clause_of_t<decltype(select_columns(dynamic(true, declare_group_by_column(v)).as(cheese)))>;
|
||||
static_assert(std::is_same<sqlpp::name_tag_of_t<T>, cheese_t::_sqlpp_name_tag>::value, "");
|
||||
static_assert(std::is_same<sqlpp::value_type_of_t<T>, sqlpp::optional<sqlpp::text>>::value, "");
|
||||
}
|
||||
|
||||
#warning: add actual tests here
|
||||
|
||||
|
@ -56,7 +56,7 @@ void test_result_row(Value v)
|
||||
auto v_not_null = sqlpp::value(v).as(r_not_null);
|
||||
const auto v_maybe_null = sqlpp::value(::sqlpp::make_optional(v)).as(r_maybe_null);
|
||||
|
||||
// Optional selectable values.
|
||||
// Dynamically selectable values.
|
||||
const auto v_opt_not_null = dynamic(true, sqlpp::value(v)).as(r_opt_not_null);
|
||||
const auto v_opt_maybe_null = dynamic(true, sqlpp::value(::sqlpp::make_optional(v))).as(r_opt_maybe_null);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user