From 465a8e700c513b060fe69ce50e3bf65d4337ac3a Mon Sep 17 00:00:00 2001 From: rbock Date: Fri, 13 Mar 2015 21:47:41 +0100 Subject: [PATCH] Fixed serialize check for tvin expressions --- include/sqlpp11/assignment.h | 5 ++--- include/sqlpp11/expression.h | 8 ++++---- tests/InsertTest.cpp | 1 + tests/InterpretTest.cpp | 1 + tests/SelectTest.cpp | 5 +++++ 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/sqlpp11/assignment.h b/include/sqlpp11/assignment.h index 4c405d6b..29e3dbd8 100644 --- a/include/sqlpp11/assignment.h +++ b/include/sqlpp11/assignment.h @@ -41,10 +41,9 @@ namespace sqlpp struct assignment_t { using _traits = make_traits; - using _nodes = detail::type_vector; - using _lhs_t = Lhs; using _rhs_t = rhs_wrap_t, trivial_value_is_null_t<_lhs_t>::value>; + using _nodes = detail::type_vector<_lhs_t, _rhs_t>; static_assert(can_be_null_t<_lhs_t>::value ? true : not (std::is_same<_rhs_t, null_t>::value or is_tvin_t<_rhs_t>::value), "column must not be null"); @@ -66,8 +65,8 @@ namespace sqlpp template struct serializer_t> { - using _serialize_check = serialize_check_of; using T = assignment_t; + using _serialize_check = serialize_check_of; static Context& _(const T& t, Context& context) { diff --git a/include/sqlpp11/expression.h b/include/sqlpp11/expression.h index 6aeebd16..d67b2d3c 100644 --- a/include/sqlpp11/expression.h +++ b/include/sqlpp11/expression.h @@ -44,9 +44,9 @@ namespace sqlpp public alias_operators> { using _traits = make_traits; - using _nodes = detail::type_vector; using _lhs_t = Lhs; using _rhs_t = rhs_wrap_t, trivial_value_is_null_t<_lhs_t>::value>; + using _nodes = detail::type_vector<_lhs_t, _rhs_t>; binary_expression_t(_lhs_t lhs, _rhs_t rhs): _lhs(lhs), @@ -66,8 +66,8 @@ namespace sqlpp template struct serializer_t> { - using _serialize_check = serialize_check_of; using T = equal_to_t; + using _serialize_check = serialize_check_of; static Context& _(const T& t, Context& context) { @@ -93,9 +93,9 @@ namespace sqlpp public alias_operators> { using _traits = make_traits; - using _nodes = detail::type_vector; using _lhs_t = Lhs; using _rhs_t = rhs_wrap_t, trivial_value_is_null_t<_lhs_t>::value>; + using _nodes = detail::type_vector<_lhs_t, _rhs_t>; binary_expression_t(Lhs lhs, _rhs_t rhs): _lhs(lhs), @@ -115,8 +115,8 @@ namespace sqlpp template struct serializer_t> { - using _serialize_check = serialize_check_of; using T = not_equal_to_t; + using _serialize_check = serialize_check_of; static Context& _(const T& t, Context& context) { diff --git a/tests/InsertTest.cpp b/tests/InsertTest.cpp index 99a2d0c5..99d8cf77 100644 --- a/tests/InsertTest.cpp +++ b/tests/InsertTest.cpp @@ -75,6 +75,7 @@ int main() db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::verbatim("17+4"))); db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::null)); db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::default_value)); + db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::tvin(0))); return 0; } diff --git a/tests/InterpretTest.cpp b/tests/InterpretTest.cpp index 3aa3487c..8432aaad 100644 --- a/tests/InterpretTest.cpp +++ b/tests/InterpretTest.cpp @@ -62,6 +62,7 @@ int main() serialize(t.alpha != 0, printer).str(); serialize(t.gamma != sqlpp::tvin(false), printer).str(); serialize(t.alpha == 7, printer).str(); + serialize(t.delta = sqlpp::tvin(0), printer).str(); serialize(t.beta + "kaesekuchen", printer).str(); serialize(sqlpp::select(), printer).str(); diff --git a/tests/SelectTest.cpp b/tests/SelectTest.cpp index ba5f9bec..abe078da 100644 --- a/tests/SelectTest.cpp +++ b/tests/SelectTest.cpp @@ -85,6 +85,11 @@ int main() std::cout << row.count << std::endl; } + for (const auto& row : db(select(count(t.alpha), avg(t.alpha)).from(t).where(t.alpha == sqlpp::tvin(0)))) + { + std::cout << row.count << 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();