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

Fixed serialize check for tvin expressions

This commit is contained in:
rbock 2015-03-13 21:47:41 +01:00
parent 3b23615dae
commit 465a8e700c
5 changed files with 13 additions and 7 deletions

View File

@ -41,10 +41,9 @@ namespace sqlpp
struct assignment_t
{
using _traits = make_traits<no_value_t, tag::is_assignment>;
using _nodes = detail::type_vector<Lhs, Rhs>;
using _lhs_t = Lhs;
using _rhs_t = rhs_wrap_t<allow_tvin_t<Rhs>, 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<typename Context, typename Lhs, typename Rhs>
struct serializer_t<Context, assignment_t<Lhs, Rhs>>
{
using _serialize_check = serialize_check_of<Context, Lhs, Rhs>;
using T = assignment_t<Lhs, Rhs>;
using _serialize_check = serialize_check_of<Context, typename T::_lhs_t, typename T::_rhs_t>;
static Context& _(const T& t, Context& context)
{

View File

@ -44,9 +44,9 @@ namespace sqlpp
public alias_operators<binary_expression_t<Lhs, op::equal_to, Rhs>>
{
using _traits = make_traits<boolean, tag::is_expression>;
using _nodes = detail::type_vector<Lhs, Rhs>;
using _lhs_t = Lhs;
using _rhs_t = rhs_wrap_t<allow_tvin_t<Rhs>, 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<typename Context, typename Lhs, typename Rhs>
struct serializer_t<Context, equal_to_t<Lhs, Rhs>>
{
using _serialize_check = serialize_check_of<Context, Lhs, Rhs>;
using T = equal_to_t<Lhs, Rhs>;
using _serialize_check = serialize_check_of<Context, typename T::_lhs_t, typename T::_rhs_t>;
static Context& _(const T& t, Context& context)
{
@ -93,9 +93,9 @@ namespace sqlpp
public alias_operators<binary_expression_t<Lhs, op::not_equal_to, Rhs>>
{
using _traits = make_traits<boolean, tag::is_expression>;
using _nodes = detail::type_vector<Lhs, Rhs>;
using _lhs_t = Lhs;
using _rhs_t = rhs_wrap_t<allow_tvin_t<Rhs>, 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<typename Context, typename Lhs, typename Rhs>
struct serializer_t<Context, not_equal_to_t<Lhs, Rhs>>
{
using _serialize_check = serialize_check_of<Context, Lhs, Rhs>;
using T = not_equal_to_t<Lhs, Rhs>;
using _serialize_check = serialize_check_of<Context, typename T::_lhs_t, typename T::_rhs_t>;
static Context& _(const T& t, Context& context)
{

View File

@ -75,6 +75,7 @@ int main()
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::verbatim<sqlpp::integer>("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;
}

View File

@ -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();

View File

@ -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();