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

Adjust WITH clause to serialize RECURSIVE where required

This commit is contained in:
rbock 2015-02-09 18:44:25 +01:00
parent f50500ba8b
commit a5c8b40b07

View File

@ -45,6 +45,8 @@ namespace sqlpp
template<typename Database, typename... Expressions> template<typename Database, typename... Expressions>
struct with_data_t struct with_data_t
{ {
using _is_recursive = logic::any_t<Expressions::_is_recursive...>;
with_data_t(Expressions... expressions): with_data_t(Expressions... expressions):
_expressions(expressions...) _expressions(expressions...)
{} {}
@ -74,7 +76,6 @@ namespace sqlpp
using _tags = detail::type_set<>; using _tags = detail::type_set<>;
}; };
using _is_dynamic = is_database<Database>; using _is_dynamic = is_database<Database>;
// Data // Data
@ -172,6 +173,8 @@ namespace sqlpp
{ {
// FIXME: If there is a recursive CTE, add a "RECURSIVE" here // FIXME: If there is a recursive CTE, add a "RECURSIVE" here
context << " WITH "; context << " WITH ";
if (T::_is_recursive::value)
context << "RECURSIVE ";
interpret_tuple(t._expressions, ',', context); interpret_tuple(t._expressions, ',', context);
return context; return context;
} }