diff --git a/tests/InsertTest.cpp b/tests/InsertTest.cpp index 7a50f1c4..68b06d82 100644 --- a/tests/InsertTest.cpp +++ b/tests/InsertTest.cpp @@ -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)); diff --git a/tests/PreparedTest.cpp b/tests/PreparedTest.cpp index dcf339a5..ae4cc16e 100644 --- a/tests/PreparedTest.cpp +++ b/tests/PreparedTest.cpp @@ -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; + using T = sqlpp::parameters_of; static_assert(std::is_same>::value, "type requirement"); } // three parameters in expression { - using T = sqlpp::parameters_of; + using T = sqlpp::parameters_of; static_assert(std::tuple_size::value == 3, "type requirement"); static_assert(std::is_same>::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; T npl; static_assert(std::is_same::_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); diff --git a/tests/RemoveTest.cpp b/tests/RemoveTest.cpp index 52636a57..0ea34df1 100644 --- a/tests/RemoveTest.cpp +++ b/tests/RemoveTest.cpp @@ -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::value, "type requirement"); diff --git a/tests/SelectTest.cpp b/tests/SelectTest.cpp index 14979a1d..9a94694b 100644 --- a/tests/SelectTest.cpp +++ b/tests/SelectTest.cpp @@ -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; } diff --git a/tests/SelectTypeTest.cpp b/tests/SelectTypeTest.cpp index 8e19ec4e..2361a623 100644 --- a/tests/SelectTypeTest.cpp +++ b/tests/SelectTypeTest.cpp @@ -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::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::value, "a multi_column is not a value"); + //static_assert(not sqlpp::is_expression_t::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::value, "TabBar.alpha has to be a numeric"); ((t.alpha + 7) + 4).asc(); static_assert(sqlpp::is_boolean_t::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::value, "an alias of alpha should be a named expression"); static_assert(sqlpp::is_alias_t::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::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::value, "no column list"); - static_assert(sqlpp::is_from_t::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::value, "should be the same"); - */ static_assert(sqlpp::is_boolean_t::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) diff --git a/tests/UpdateTest.cpp b/tests/UpdateTest.cpp index 6f7a0c0b..e3f8de62 100644 --- a/tests/UpdateTest.cpp +++ b/tests/UpdateTest.cpp @@ -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));