From b3ef68101fe924ece0557b6f4706baf1317e4d97 Mon Sep 17 00:00:00 2001 From: rbock Date: Fri, 3 Oct 2014 08:51:27 +0200 Subject: [PATCH] Fixed bug in in() serialization in(select(...)) did have an extra set of braces, which lead to different behaviour. Thanks to Thomas Marsh for finding the bug --- include/sqlpp11/in.h | 6 +++++- tests/InterpretTest.cpp | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/sqlpp11/in.h b/include/sqlpp11/in.h index e3bf0915..3d8a98a0 100644 --- a/include/sqlpp11/in.h +++ b/include/sqlpp11/in.h @@ -79,7 +79,11 @@ namespace sqlpp { serialize(t._operand, context); context << (t._inverted ? " NOT IN(" : " IN("); - interpret_tuple(t._args, ',', context); + if (sizeof...(Args) == 1) + serialize(std::get<0>(t._args), context); // FIXME: this is a bit of a hack until there is a better overall strategy for using braces + // see https://github.com/rbock/sqlpp11/issues/18 + else + interpret_tuple(t._args, ',', context); context << ')'; return context; } diff --git a/tests/InterpretTest.cpp b/tests/InterpretTest.cpp index 6d0943ac..c3813a24 100644 --- a/tests/InterpretTest.cpp +++ b/tests/InterpretTest.cpp @@ -179,6 +179,9 @@ int main() printer.reset(); std::cerr << serialize(x, printer).str() << std::endl; + printer.reset(); + std::cerr << serialize(select(all_of(t)).from(t).where(t.alpha.in(select(f.epsilon).from(f).where(true))), printer).str() << std::endl; + return 0;