diff --git a/include/sqlpp11/in.h b/include/sqlpp11/in.h index 1c2bcc87..1ad51217 100644 --- a/include/sqlpp11/in.h +++ b/include/sqlpp11/in.h @@ -56,8 +56,6 @@ namespace sqlpp using _traits = make_traits; using _nodes = detail::type_vector; - static_assert(sizeof...(Args) > 0, "in() requires at least one argument"); - using _auto_alias_t = in_alias_t; in_t(Operand operand, Args... args) : _operand(operand), _args(args...) @@ -93,6 +91,19 @@ namespace sqlpp } }; + template + struct serializer_t> + { + using _serialize_check = consistent_t; + using T = in_t; + + static Context& _(const T&, Context& context) + { + serialize(boolean_operand{false}, context); + return context; + } + }; + template struct value_list_t; @@ -107,7 +118,7 @@ namespace sqlpp const auto& value_list = std::get<0>(t._args); if (value_list._container.empty()) { - context << " 'operand in empty list' = 'false' "; + serialize(boolean_operand{false}, context); } else { diff --git a/include/sqlpp11/not_in.h b/include/sqlpp11/not_in.h index 619a6b96..80676e64 100644 --- a/include/sqlpp11/not_in.h +++ b/include/sqlpp11/not_in.h @@ -56,8 +56,6 @@ namespace sqlpp using _traits = make_traits; using _nodes = detail::type_vector; - static_assert(sizeof...(Args) > 0, "not_in() requires at least one argument"); - using _auto_alias_t = not_in_alias_t; not_in_t(Operand operand, Args... args) : _operand(operand), _args(args...) @@ -93,6 +91,19 @@ namespace sqlpp } }; + template + struct serializer_t> + { + using _serialize_check = consistent_t; + using T = not_in_t; + + static Context& _(const T&, Context& context) + { + serialize(boolean_operand{true}, context); + return context; + } + }; + template struct value_list_t; @@ -107,7 +118,7 @@ namespace sqlpp const auto& value_list = std::get<0>(t._args); if (value_list._container.empty()) { - context << " 'operand not in empty list' != 'false' "; + serialize(boolean_operand{true}, context); } else { diff --git a/include/sqlpp11/result_row.h b/include/sqlpp11/result_row.h index 4eff7ca0..ba032005 100644 --- a/include/sqlpp11/result_row.h +++ b/include/sqlpp11/result_row.h @@ -63,6 +63,12 @@ namespace sqlpp { _field::operator()()._bind(target, index); } + + template + void _post_bind(Target& target) + { + _field::operator()()._post_bind(target, index); + } }; template @@ -91,6 +97,12 @@ namespace sqlpp { _multi_field::operator()()._bind(target); } + + template + void _post_bind(Target& target) + { + _multi_field::operator()()._post_bind(target); + } }; template @@ -117,6 +129,13 @@ namespace sqlpp using swallow = int[]; (void)swallow{(result_field::_bind(target), 0)...}; } + + template + void _post_bind(Target& target) + { + using swallow = int[]; + (void)swallow{(result_field::_post_bind(target), 0)...}; + } }; } @@ -175,6 +194,12 @@ namespace sqlpp { _impl::_bind(target); } + + template + void _post_bind(Target& target) + { + _impl::_post_bind(target); + } }; template @@ -254,6 +279,19 @@ namespace sqlpp ++index; } } + + template + void _post_bind(Target& target) + { + _impl::_post_bind(target); + + std::size_t index = _field_index_sequence::_next_index; + for (const auto& field_name : _dynamic_field_names) + { + _dynamic_fields.at(field_name)._post_bind(target, index); + ++index; + } + } }; template diff --git a/tests/Interpret.cpp b/tests/Interpret.cpp index 50505a95..a9cfcd6a 100644 --- a/tests/Interpret.cpp +++ b/tests/Interpret.cpp @@ -106,6 +106,7 @@ int Interpret(int, char**) serialize(update(t), printer).str(); serialize(update(t).set(t.gamma = true), printer).str(); serialize(update(t).set(t.gamma = true).where(t.beta.in("kaesekuchen", "cheesecake")), printer).str(); + serialize(update(t).set(t.gamma = true).where(t.beta.in()), printer).str(); serialize(remove_from(t), printer).str(); serialize(remove_from(t).using_(t), printer).str(); @@ -203,6 +204,12 @@ int Interpret(int, char**) std::cerr << serialize(select(all_of(t)).from(t).where(t.alpha.in(select(f.epsilon).from(f).where(true))), printer) .str() << std::endl; + printer.reset(); + std::cerr << serialize(select(all_of(t)).from(t).where(t.alpha.in()), printer).str() << std::endl; + + printer.reset(); + std::cerr << serialize(select(all_of(t)).from(t).where(t.alpha.not_in()), printer).str() << std::endl; + auto schema = db.attach("lorem"); auto s = schema_qualified_table(schema, t).as(sqlpp::alias::x);