mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-04 20:20:59 -06:00
Fixed most of the compiler warnings about unused variables in test programs
This commit is contained in:
@@ -35,13 +35,7 @@ MockDb::_serializer_context_t printer;
|
||||
int main()
|
||||
{
|
||||
test::TabBar t;
|
||||
test::TabFoo f;
|
||||
|
||||
auto x = t.alpha = 7;
|
||||
auto y = t.beta = "kaesekuchen";
|
||||
auto z = t.gamma = true;
|
||||
auto a = t.alpha;
|
||||
a = t.alpha;
|
||||
//test::TabFoo f;
|
||||
|
||||
{
|
||||
using T = decltype(insert_into(t));
|
||||
|
||||
@@ -35,7 +35,7 @@ MockDb db = {};
|
||||
|
||||
int main()
|
||||
{
|
||||
test::TabFoo f;
|
||||
//test::TabFoo f;
|
||||
test::TabBar t;
|
||||
|
||||
// empty parameter lists
|
||||
@@ -65,20 +65,20 @@ int main()
|
||||
|
||||
// single parameter in larger expression
|
||||
{
|
||||
using T = sqlpp::parameters_of<decltype(t.beta.like("%") and t.alpha == parameter(t.alpha) or t.gamma != false)>;
|
||||
using T = sqlpp::parameters_of<decltype((t.beta.like("%") and t.alpha == parameter(t.alpha)) or t.gamma != false)>;
|
||||
static_assert(std::is_same<T, std::tuple<decltype(parameter(t.alpha))>>::value, "type requirement");
|
||||
}
|
||||
|
||||
// three parameters in expression
|
||||
{
|
||||
using T = sqlpp::parameters_of<decltype(t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha) or t.gamma != parameter(t.gamma))>;
|
||||
using T = sqlpp::parameters_of<decltype((t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha)) or t.gamma != parameter(t.gamma))>;
|
||||
static_assert(std::tuple_size<T>::value == 3, "type requirement");
|
||||
static_assert(std::is_same<T, std::tuple<decltype(parameter(t.beta)), decltype(parameter(t.alpha)),decltype(parameter(t.gamma))>>::value, "type requirement");
|
||||
}
|
||||
|
||||
// OK, fine, now create a named parameter list from an expression
|
||||
{
|
||||
using Exp = decltype(t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha) or t.gamma != parameter(t.gamma));
|
||||
using Exp = decltype((t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha)) or t.gamma != parameter(t.gamma));
|
||||
using T = sqlpp::make_parameter_list_t<Exp>;
|
||||
T npl;
|
||||
static_assert(std::is_same<typename sqlpp::value_type_of<decltype(t.alpha)>::_parameter_t, decltype(npl.alpha)>::value, "type requirement");
|
||||
@@ -88,7 +88,7 @@ int main()
|
||||
|
||||
// Wonderful, now take a look at the parameter list of a select
|
||||
{
|
||||
auto s = select(all_of(t)).from(t).where(t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha) or t.gamma != parameter(t.gamma));
|
||||
auto s = select(all_of(t)).from(t).where((t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha)) or t.gamma != parameter(t.gamma));
|
||||
auto p = db.prepare(s);
|
||||
p.params.alpha = 7;
|
||||
using S = decltype(s);
|
||||
|
||||
@@ -37,10 +37,6 @@ int main()
|
||||
{
|
||||
test::TabBar t;
|
||||
|
||||
auto x = t.alpha = 7;
|
||||
auto y = t.beta = "kaesekuchen";
|
||||
auto z = t.gamma = true;
|
||||
|
||||
{
|
||||
using T = decltype(remove_from(t));
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
|
||||
@@ -54,12 +54,14 @@ int main()
|
||||
{
|
||||
int64_t a = row.alpha;
|
||||
const std::string b = row.beta;
|
||||
std::cout << a << ", " << b << std::endl;
|
||||
}
|
||||
|
||||
for (const auto& row : db(select(all_of(t).as(t)).from(t).where(true)))
|
||||
{
|
||||
int64_t a = row.tabBar.alpha;
|
||||
const std::string b = row.tabBar.beta;
|
||||
std::cout << a << ", " << b << std::endl;
|
||||
}
|
||||
|
||||
for (const auto& row : db(select(all_of(t).as(t), t.gamma).from(t).where(t.alpha > 7)))
|
||||
@@ -67,9 +69,11 @@ int main()
|
||||
int64_t a = row.tabBar.alpha;
|
||||
const std::string b = row.tabBar.beta;
|
||||
const bool g = row.gamma;
|
||||
std::cout << a << ", " << b << ", " << g << std::endl;
|
||||
}
|
||||
|
||||
auto stat = sqlpp::select().columns(all_of(t)).flags(sqlpp::all).from(t).extra_tables(f,t).where(t.alpha > 0).group_by(t.alpha).order_by(t.gamma.asc()).having(t.gamma).limit(7).offset(19);
|
||||
|
||||
auto s = dynamic_select(db).dynamic_columns(all_of(t)).dynamic_flags().dynamic_from(t).extra_tables(f,t).dynamic_where().dynamic_group_by(t.alpha).dynamic_order_by().dynamic_having(t.gamma).dynamic_limit().dynamic_offset();
|
||||
s.select_flags.add(sqlpp::distinct);
|
||||
s.selected_columns.add(f.omega);
|
||||
@@ -83,12 +87,13 @@ int main()
|
||||
for (const auto& row : db(s))
|
||||
{
|
||||
int64_t a = row.alpha;
|
||||
std::cout << a << std::endl;
|
||||
}
|
||||
|
||||
printer.reset();
|
||||
std::cerr << serialize(s, printer).str() << std::endl;
|
||||
|
||||
auto X = select(all_of(t)).from(t).as(t.alpha);
|
||||
printer.reset();
|
||||
std::cerr << serialize(stat, printer).str() << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -289,8 +289,11 @@ int main()
|
||||
// Test that a multicolumn is not a value
|
||||
{
|
||||
auto m = multi_column(t.alpha, t.beta).as(alias::a);
|
||||
static_assert(not sqlpp::is_expression_t<decltype(m)>::value, "a multi_column is not a value");
|
||||
|
||||
#warning: A multicolumn cannot be used if the select is to be used like a table
|
||||
auto a = select(m).from(t).as(alias::b).a;
|
||||
// FIXME: Do we really need that test? multi_column is a no_value static_assert(not sqlpp::is_expression_t<decltype(a)>::value, "a multi_column is not a value");
|
||||
//static_assert(not sqlpp::is_expression_t<decltype(a)>::value, "a multi_column is not a value");
|
||||
}
|
||||
// Test that result sets with identical name/value combinations have identical types
|
||||
{
|
||||
@@ -307,6 +310,7 @@ int main()
|
||||
for (const auto& row : db(select(all_of(t)).from(t).where(true)))
|
||||
{
|
||||
int64_t a = row.alpha;
|
||||
std::cout << a << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
@@ -344,8 +348,6 @@ int main()
|
||||
static_assert(sqlpp::is_numeric_t<decltype(t.alpha)>::value, "TabBar.alpha has to be a numeric");
|
||||
((t.alpha + 7) + 4).asc();
|
||||
static_assert(sqlpp::is_boolean_t<decltype(t.gamma == t.gamma)>::value, "Comparison expression have to be boolean");
|
||||
auto x = (t.gamma == true) and (t.alpha == 7);
|
||||
auto y = t.gamma and true and t.gamma;
|
||||
!t.gamma;
|
||||
t.beta < "kaesekuchen";
|
||||
serialize(t.beta + "hallenhalma", printer).str();
|
||||
@@ -356,25 +358,9 @@ int main()
|
||||
static_assert(sqlpp::is_named_expression_t<decltype(t.alpha.as(alias::a))>::value, "an alias of alpha should be a named expression");
|
||||
static_assert(sqlpp::is_alias_t<decltype(t.alpha.as(alias::a))>::value, "an alias of alpha should be an alias");
|
||||
|
||||
auto z = select(t.alpha).from(t) == 7;
|
||||
auto l = t.as(alias::left);
|
||||
auto r = select(t.gamma.as(alias::a)).from(t).where(t.gamma == true).as(alias::right);
|
||||
using R = decltype(r);
|
||||
static_assert(sqlpp::is_boolean_t<decltype(select(t.gamma).from(t))>::value, "select(bool) has to be a bool");
|
||||
auto s = select(r.a).from(r);
|
||||
using RA = decltype(r.a);
|
||||
using S = decltype(s);
|
||||
/*
|
||||
using SCL = typename S::_column_list_t;
|
||||
using SF = typename S::_from_t;
|
||||
static_assert(sqlpp::is_select_column_list_t<SCL>::value, "no column list");
|
||||
static_assert(sqlpp::is_from_t<SF>::value, "no from list");
|
||||
using SCL_T = typename SCL::_table_set;
|
||||
using SF_T = typename SF::_table_set;
|
||||
static_assert(SCL_T::size::value == 1, "unexpected table_set in column_list");
|
||||
static_assert(SF_T::size::value == 1, "unexpected table_set in from");
|
||||
static_assert(std::is_same<SCL_T, SF_T>::value, "should be the same");
|
||||
*/
|
||||
static_assert(sqlpp::is_boolean_t<decltype(select(r.a).from(r))>::value, "select(bool) has to be a bool");
|
||||
auto s1 = sqlpp::select().flags(sqlpp::distinct, sqlpp::straight_join).columns(l.alpha, l.beta, select(r.a).from(r))
|
||||
.from(r,t,l)
|
||||
|
||||
@@ -35,11 +35,7 @@ MockDb::_serializer_context_t printer;
|
||||
int main()
|
||||
{
|
||||
test::TabBar t;
|
||||
test::TabFoo f;
|
||||
|
||||
auto x = t.alpha = 7;
|
||||
auto y = t.beta = "kaesekuchen";
|
||||
auto z = t.gamma = true;
|
||||
//test::TabFoo f;
|
||||
|
||||
{
|
||||
using T = decltype(update(t));
|
||||
|
||||
Reference in New Issue
Block a user