mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-05 20:50:34 -06:00
Started to replace serializer_t
This commit is contained in:
@@ -84,28 +84,22 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Context, typename Flag, typename Expr>
|
||||
struct serializer_t<Context, avg_t<Flag, Expr>>
|
||||
Context& serialize(const avg_t<Flag, Expr>& t, Context& context)
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, Flag, Expr>;
|
||||
using T = avg_t<Flag, Expr>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
context << "AVG(";
|
||||
if (std::is_same<distinct_t, Flag>::value)
|
||||
{
|
||||
context << "AVG(";
|
||||
if (std::is_same<distinct_t, Flag>::value)
|
||||
{
|
||||
serialize(Flag(), context);
|
||||
context << ' ';
|
||||
serialize_operand(t._expr, context);
|
||||
}
|
||||
else
|
||||
{
|
||||
serialize(t._expr, context);
|
||||
}
|
||||
context << ")";
|
||||
return context;
|
||||
serialize(Flag(), context);
|
||||
context << ' ';
|
||||
serialize_operand(t._expr, context);
|
||||
}
|
||||
};
|
||||
else
|
||||
{
|
||||
serialize(t._expr, context);
|
||||
}
|
||||
context << ")";
|
||||
return context;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto avg(T t) -> avg_t<noop, wrap_operand_t<T>>
|
||||
|
||||
@@ -87,28 +87,22 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Context, typename Flag, typename Expr>
|
||||
struct serializer_t<Context, count_t<Flag, Expr>>
|
||||
Context& serialize(const count_t<Flag, Expr>& t, Context& context)
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, Flag, Expr>;
|
||||
using T = count_t<Flag, Expr>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
context << "COUNT(";
|
||||
if (std::is_same<distinct_t, Flag>::value)
|
||||
{
|
||||
context << "COUNT(";
|
||||
if (std::is_same<distinct_t, Flag>::value)
|
||||
{
|
||||
serialize(Flag(), context);
|
||||
context << ' ';
|
||||
serialize_operand(t._expr, context);
|
||||
}
|
||||
else
|
||||
{
|
||||
serialize(t._expr, context);
|
||||
}
|
||||
context << ")";
|
||||
return context;
|
||||
serialize(Flag(), context);
|
||||
context << ' ';
|
||||
serialize_operand(t._expr, context);
|
||||
}
|
||||
};
|
||||
else
|
||||
{
|
||||
serialize(t._expr, context);
|
||||
}
|
||||
context << ")";
|
||||
return context;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto count(T t) -> count_t<noop, wrap_operand_t<T>>
|
||||
|
||||
@@ -80,19 +80,13 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Context, typename Expr>
|
||||
struct serializer_t<Context, max_t<Expr>>
|
||||
Context& serialize(const max_t<Expr>& t, Context& context)
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, Expr>;
|
||||
using T = max_t<Expr>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
context << "MAX(";
|
||||
serialize(t._expr, context);
|
||||
context << ")";
|
||||
return context;
|
||||
}
|
||||
};
|
||||
context << "MAX(";
|
||||
serialize(t._expr, context);
|
||||
context << ")";
|
||||
return context;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto max(T t) -> max_t<wrap_operand_t<T>>
|
||||
|
||||
@@ -80,19 +80,13 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Context, typename Expr>
|
||||
struct serializer_t<Context, min_t<Expr>>
|
||||
Context& serialize(const min_t<Expr>& t, Context& context)
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, Expr>;
|
||||
using T = min_t<Expr>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
context << "MIN(";
|
||||
serialize(t._expr, context);
|
||||
context << ")";
|
||||
return context;
|
||||
}
|
||||
};
|
||||
context << "MIN(";
|
||||
serialize(t._expr, context);
|
||||
context << ")";
|
||||
return context;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto min(T t) -> min_t<wrap_operand_t<T>>
|
||||
|
||||
@@ -84,29 +84,22 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Context, typename Flag, typename Expr>
|
||||
struct serializer_t<Context, sum_t<Flag, Expr>>
|
||||
Context& serialize(const sum_t<Flag, Expr>& t, Context& context)
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, Flag, Expr>;
|
||||
using T = sum_t<Flag, Expr>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
context << "SUM(";
|
||||
if (std::is_same<distinct_t, Flag>::value)
|
||||
{
|
||||
context << "SUM(";
|
||||
if (std::is_same<distinct_t, Flag>::value)
|
||||
{
|
||||
serialize(Flag(), context);
|
||||
context << ' ';
|
||||
serialize_operand(t._expr, context);
|
||||
}
|
||||
else
|
||||
{
|
||||
serialize(t._expr, context);
|
||||
}
|
||||
|
||||
context << ")";
|
||||
return context;
|
||||
serialize(Flag(), context);
|
||||
context << ' ';
|
||||
serialize_operand(t._expr, context);
|
||||
}
|
||||
};
|
||||
else
|
||||
{
|
||||
serialize(t._expr, context);
|
||||
}
|
||||
context << ")";
|
||||
return context;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto sum(T t) -> sum_t<noop, wrap_operand_t<T>>
|
||||
|
||||
@@ -49,18 +49,12 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Context, typename PreJoin, typename On>
|
||||
struct serializer_t<Context, dynamic_join_t<PreJoin, On>>
|
||||
Context& serialize(const dynamic_join_t<PreJoin, On>& t, Context& context)
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, PreJoin, On>;
|
||||
using T = dynamic_join_t<PreJoin, On>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
serialize(t._pre_join, context);
|
||||
serialize(t._on, context);
|
||||
return context;
|
||||
}
|
||||
};
|
||||
serialize(t._pre_join, context);
|
||||
serialize(t._on, context);
|
||||
return context;
|
||||
}
|
||||
} // namespace sqlpp
|
||||
|
||||
#endif
|
||||
|
||||
@@ -105,19 +105,13 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Context, typename JoinType, typename Rhs>
|
||||
struct serializer_t<Context, dynamic_pre_join_t<JoinType, Rhs>>
|
||||
Context& serialize(const dynamic_pre_join_t<JoinType, Rhs>& t, Context& context)
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, Rhs>;
|
||||
using T = dynamic_pre_join_t<JoinType, Rhs>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
context << JoinType::_name;
|
||||
context << " JOIN ";
|
||||
serialize(t._rhs, context);
|
||||
return context;
|
||||
}
|
||||
};
|
||||
context << JoinType::_name;
|
||||
context << " JOIN ";
|
||||
serialize(t._rhs, context);
|
||||
return context;
|
||||
}
|
||||
|
||||
template <typename JoinType, typename Table>
|
||||
using make_dynamic_pre_join_t = typename std::conditional<check_dynamic_pre_join_t<Table>::value,
|
||||
|
||||
@@ -84,8 +84,10 @@ namespace sqlpp
|
||||
static_check_t<detail::is_disjunct_from<_joined_table_names, _known_table_names>::value,
|
||||
assert_from_add_unique_names>,
|
||||
static_check_t<detail::is_subset_of<_required_tables, _known_tables>::value,
|
||||
assert_from_add_no_required_tables>,
|
||||
sqlpp::serialize_check_t<serializer_context_of<typename From::_database_t>, DynamicJoin>>;
|
||||
assert_from_add_no_required_tables>
|
||||
// FIXME: Replace this with consistency check?
|
||||
// sqlpp::serialize_check_t<serializer_context_of<typename From::_database_t>, DynamicJoin>
|
||||
>;
|
||||
};
|
||||
|
||||
template <typename From, typename DynamicJoin>
|
||||
@@ -290,22 +292,16 @@ namespace sqlpp
|
||||
|
||||
// Interpreters
|
||||
template <typename Context, typename Database, typename Table>
|
||||
struct serializer_t<Context, from_data_t<Database, Table>>
|
||||
Context& serialize(const from_data_t<Database, Table>& t, Context& context)
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, Table>;
|
||||
using T = from_data_t<Database, Table>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
context << " FROM ";
|
||||
serialize(t._table, context);
|
||||
if (not t._dynamic_tables.empty())
|
||||
{
|
||||
context << " FROM ";
|
||||
serialize(t._table, context);
|
||||
if (not t._dynamic_tables.empty())
|
||||
{
|
||||
interpret_list(t._dynamic_tables, "", context);
|
||||
}
|
||||
return context;
|
||||
interpret_list(t._dynamic_tables, "", context);
|
||||
}
|
||||
};
|
||||
return context;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto from(T&& t) -> decltype(statement_t<void, no_from_t>().from(std::forward<T>(t)))
|
||||
|
||||
@@ -49,9 +49,9 @@ namespace sqlpp
|
||||
interpretable_t& operator=(interpretable_t&&) = default;
|
||||
~interpretable_t() = default;
|
||||
|
||||
_serializer_context_t& serialize(_serializer_context_t& context) const
|
||||
_serializer_context_t& interpret(_serializer_context_t& context) const
|
||||
{
|
||||
return _impl->serialize(context);
|
||||
return _impl->interpret(context);
|
||||
}
|
||||
|
||||
bool _requires_braces;
|
||||
@@ -60,7 +60,7 @@ namespace sqlpp
|
||||
struct _impl_base
|
||||
{
|
||||
virtual ~_impl_base() = default;
|
||||
virtual _serializer_context_t& serialize(_serializer_context_t& context) const = 0;
|
||||
virtual _serializer_context_t& interpret(_serializer_context_t& context) const = 0;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@@ -71,9 +71,9 @@ namespace sqlpp
|
||||
{
|
||||
}
|
||||
|
||||
_serializer_context_t& serialize(_serializer_context_t& context) const
|
||||
_serializer_context_t& interpret(_serializer_context_t& context) const
|
||||
{
|
||||
::sqlpp::serialize(_t, context);
|
||||
serialize(_t, context);
|
||||
return context;
|
||||
}
|
||||
|
||||
@@ -84,27 +84,21 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Context, typename Database>
|
||||
struct serializer_t<Context, interpretable_t<Database>>
|
||||
Context& serialize(const interpretable_t<Database>& t, Context& context)
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using T = interpretable_t<Database>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
if (t._requires_braces)
|
||||
{
|
||||
if (t._requires_braces)
|
||||
{
|
||||
context << '(';
|
||||
t.serialize(context);
|
||||
context << ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
t.serialize(context);
|
||||
}
|
||||
|
||||
return context;
|
||||
context << '(';
|
||||
t.interpret(context);
|
||||
context << ')';
|
||||
}
|
||||
};
|
||||
else
|
||||
{
|
||||
t.interpret(context);
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
} // namespace sqlpp
|
||||
|
||||
#endif
|
||||
|
||||
@@ -68,15 +68,11 @@ namespace sqlpp
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Context, typename List>
|
||||
struct serializable_list_interpreter_t
|
||||
template <typename Db, typename Separator, typename Context>
|
||||
auto interpret_list(const interpretable_list_t<Db>& t, const Separator& separator, Context& context)
|
||||
-> Context&
|
||||
{
|
||||
using T = List;
|
||||
|
||||
template <typename Separator>
|
||||
static Context& _(const T& t, const Separator& separator, Context& context)
|
||||
{
|
||||
bool first = true;
|
||||
bool first = true;
|
||||
for (const auto entry : t._serializables)
|
||||
{
|
||||
if (not first)
|
||||
@@ -87,26 +83,13 @@ namespace sqlpp
|
||||
serialize(entry, context);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
struct serializable_list_interpreter_t<Context, interpretable_list_t<void>>
|
||||
template <typename Separator, typename Context>
|
||||
auto interpret_list(const interpretable_list_t<void>&, const Separator&, Context& context)
|
||||
-> Context&
|
||||
{
|
||||
using T = interpretable_list_t<void>;
|
||||
|
||||
template <typename Separator>
|
||||
static Context& _(const T& /*unused*/, const Separator& /* separator */, Context& context)
|
||||
{
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename Separator, typename Context>
|
||||
auto interpret_list(const T& t, const Separator& separator, Context& context)
|
||||
-> decltype(serializable_list_interpreter_t<Context, T>::_(t, separator, context))
|
||||
{
|
||||
return serializable_list_interpreter_t<Context, T>::_(t, separator, context);
|
||||
}
|
||||
} // namespace sqlpp
|
||||
|
||||
|
||||
@@ -71,19 +71,13 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Context, typename Operand>
|
||||
struct serializer_t<Context, is_not_null_t<Operand>>
|
||||
Context& serialize(const is_not_null_t<Operand>& t, Context& context)
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, Operand>;
|
||||
using T = is_not_null_t<Operand>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
context << "(";
|
||||
serialize_operand(t._operand, context);
|
||||
context << " IS NOT NULL)";
|
||||
return context;
|
||||
}
|
||||
};
|
||||
context << "(";
|
||||
serialize_operand(t._operand, context);
|
||||
context << " IS NOT NULL)";
|
||||
return context;
|
||||
}
|
||||
} // namespace sqlpp
|
||||
|
||||
#endif
|
||||
|
||||
@@ -71,19 +71,13 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Context, typename Operand>
|
||||
struct serializer_t<Context, is_null_t<Operand>>
|
||||
Context& serialize(const is_null_t<Operand>& t, Context& context)
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, Operand>;
|
||||
using T = is_null_t<Operand>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
context << "(";
|
||||
serialize_operand(t._operand, context);
|
||||
context << " IS NULL)";
|
||||
return context;
|
||||
}
|
||||
};
|
||||
context << "(";
|
||||
serialize_operand(t._operand, context);
|
||||
context << " IS NULL)";
|
||||
return context;
|
||||
}
|
||||
} // namespace sqlpp
|
||||
|
||||
#endif
|
||||
|
||||
@@ -83,18 +83,12 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Context, typename PreJoin, typename On>
|
||||
struct serializer_t<Context, join_t<PreJoin, On>>
|
||||
Context& serialize(const join_t<PreJoin, On>& t, Context& context)
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, PreJoin, On>;
|
||||
using T = join_t<PreJoin, On>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
serialize(t._pre_join, context);
|
||||
serialize(t._on, context);
|
||||
return context;
|
||||
}
|
||||
};
|
||||
serialize(t._pre_join, context);
|
||||
serialize(t._on, context);
|
||||
return context;
|
||||
}
|
||||
} // namespace sqlpp
|
||||
|
||||
#endif
|
||||
|
||||
@@ -64,30 +64,18 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Context>
|
||||
struct serializer_t<Context, on_t<unconditional_t>>
|
||||
Context& serialize(const on_t<unconditional_t>&, Context& context)
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using T = on_t<unconditional_t>;
|
||||
|
||||
static Context& _(const T& /*unused*/, Context& context)
|
||||
{
|
||||
return context;
|
||||
}
|
||||
};
|
||||
return context;
|
||||
}
|
||||
|
||||
template <typename Context, typename Expression>
|
||||
struct serializer_t<Context, on_t<Expression>>
|
||||
Context& serialize(const on_t<Expression>& t, Context& context)
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, Expression>;
|
||||
using T = on_t<Expression>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
context << " ON ";
|
||||
serialize(t._expression, context);
|
||||
return context;
|
||||
}
|
||||
};
|
||||
context << " ON ";
|
||||
serialize(t._expression, context);
|
||||
return context;
|
||||
}
|
||||
} // namespace sqlpp
|
||||
|
||||
#endif
|
||||
|
||||
@@ -134,20 +134,14 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Context, typename JoinType, typename Lhs, typename Rhs>
|
||||
struct serializer_t<Context, pre_join_t<JoinType, Lhs, Rhs>>
|
||||
Context& serialize(const pre_join_t<JoinType, Lhs, Rhs>& t, Context& context)
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, Lhs, Rhs>;
|
||||
using T = pre_join_t<JoinType, Lhs, Rhs>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
serialize(t._lhs, context);
|
||||
context << JoinType::_name;
|
||||
context << " JOIN ";
|
||||
serialize(t._rhs, context);
|
||||
return context;
|
||||
}
|
||||
};
|
||||
serialize(t._lhs, context);
|
||||
context << JoinType::_name;
|
||||
context << " JOIN ";
|
||||
serialize(t._rhs, context);
|
||||
return context;
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
@@ -424,22 +424,16 @@ namespace sqlpp
|
||||
|
||||
// Interpreters
|
||||
template <typename Context, typename Database, typename... Columns>
|
||||
struct serializer_t<Context, select_column_list_data_t<Database, Columns...>>
|
||||
Context& serialize(const select_column_list_data_t<Database, Columns...>& t, Context& context)
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, Columns...>;
|
||||
using T = select_column_list_data_t<Database, Columns...>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
interpret_tuple(t._columns, ',', context);
|
||||
if (sizeof...(Columns) and not t._dynamic_columns.empty())
|
||||
{
|
||||
interpret_tuple(t._columns, ',', context);
|
||||
if (sizeof...(Columns) and not t._dynamic_columns.empty())
|
||||
{
|
||||
context << ',';
|
||||
}
|
||||
serialize(t._dynamic_columns, context);
|
||||
return context;
|
||||
context << ',';
|
||||
}
|
||||
};
|
||||
serialize(t._dynamic_columns, context);
|
||||
return context;
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
auto select_columns(T&&... t) -> decltype(statement_t<void, no_select_column_list_t>().columns(std::forward<T>(t)...))
|
||||
|
||||
@@ -75,17 +75,11 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Context, typename Select, typename... NamedExpr>
|
||||
struct serializer_t<Context, select_pseudo_table_t<Select, NamedExpr...>>
|
||||
Context& serialize(const select_pseudo_table_t<Select, NamedExpr...>& t, Context& context)
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, Select, NamedExpr...>;
|
||||
using T = select_pseudo_table_t<Select, NamedExpr...>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
serialize(t._select, context);
|
||||
return context;
|
||||
}
|
||||
};
|
||||
serialize(t._select, context);
|
||||
return context;
|
||||
}
|
||||
} // namespace sqlpp
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,23 +33,23 @@
|
||||
namespace sqlpp
|
||||
{
|
||||
template <typename T, typename Context>
|
||||
auto serialize(const T& t, Context& context) -> decltype(serializer_t<Context, T>::_(t, context))
|
||||
auto serialize(const T& t, Context& context) -> Context&
|
||||
{
|
||||
return serializer_t<Context, T>::_(t, context);
|
||||
}
|
||||
|
||||
template <typename T, typename Context>
|
||||
auto serialize_operand(const T& t, Context& context) -> decltype(serializer_t<Context, T>::_(t, context))
|
||||
auto serialize_operand(const T& t, Context& context) -> Context&
|
||||
{
|
||||
if (requires_braces_t<T>::value)
|
||||
{
|
||||
context << '(';
|
||||
serializer_t<Context, T>::_(t, context);
|
||||
serialize(t, context);
|
||||
context << ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
serializer_t<Context, T>::_(t, context);
|
||||
serialize(t, context);
|
||||
}
|
||||
|
||||
return context;
|
||||
|
||||
@@ -45,9 +45,9 @@ namespace sqlpp
|
||||
{
|
||||
using _serialize_check = assert_serializer_specialization_t;
|
||||
|
||||
static void _(const T& /*unused*/, Context& /*unused*/)
|
||||
static void _(const T& t, Context& /*unused*/)
|
||||
{
|
||||
_serialize_check{};
|
||||
_serialize_check{t};
|
||||
}
|
||||
};
|
||||
} // namespace sqlpp
|
||||
|
||||
@@ -250,21 +250,15 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Context, typename Database, typename... Policies>
|
||||
struct serializer_t<Context, statement_t<Database, Policies...>>
|
||||
Context& serialize(const statement_t<Database, Policies...>& t, Context& context)
|
||||
{
|
||||
using P = detail::statement_policies_t<Database, Policies...>;
|
||||
using _serialize_check = serialize_check_of<Context, typename Policies::template _base_t<P>::_data_t...>;
|
||||
using T = statement_t<Database, Policies...>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
using swallow = int[];
|
||||
(void)swallow{0,
|
||||
(serialize(static_cast<const typename Policies::template _base_t<P>&>(t)()._data, context), 0)...};
|
||||
using swallow = int[];
|
||||
(void)swallow{0, (serialize(static_cast<const typename Policies::template _base_t<P>&>(t)()._data, context), 0)...};
|
||||
|
||||
return context;
|
||||
}
|
||||
};
|
||||
return context;
|
||||
}
|
||||
|
||||
template <typename NameData, typename Tag = tag::is_noop>
|
||||
struct statement_name_t
|
||||
|
||||
@@ -37,15 +37,11 @@
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct table_base_t
|
||||
{
|
||||
};
|
||||
|
||||
// workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2173198
|
||||
// template <typename Table, typename... ColumnSpec>
|
||||
// struct table_t : public table_base_t, public member_t<ColumnSpec, column_t<Table, ColumnSpec>>...
|
||||
template <typename Table, typename... ColumnSpec>
|
||||
struct table_t : public table_base_t, public ColumnSpec::_alias_t::template _member_t<column_t<Table, ColumnSpec>>...
|
||||
struct table_t : public ColumnSpec::_alias_t::template _member_t<column_t<Table, ColumnSpec>>...
|
||||
{
|
||||
using _traits = make_traits<no_value_t, tag::is_raw_table, tag::is_table>;
|
||||
|
||||
@@ -109,21 +105,12 @@ namespace sqlpp
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Context, typename X>
|
||||
struct serializer_t<
|
||||
Context,
|
||||
X,
|
||||
typename std::enable_if<std::is_base_of<table_base_t, X>::value and not is_pseudo_table_t<X>::value, void>::type>
|
||||
template <typename Context, typename Table, typename... ColumnSpec>
|
||||
Context& serialize(const table_t<Table, ColumnSpec...>& /*unused*/, Context& context)
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using T = X;
|
||||
|
||||
static Context& _(const T& /*unused*/, Context& context)
|
||||
{
|
||||
context << name_of<T>::template char_ptr<Context>();
|
||||
return context;
|
||||
}
|
||||
};
|
||||
context << name_of<Table>::template char_ptr<Context>();
|
||||
return context;
|
||||
}
|
||||
} // namespace sqlpp
|
||||
|
||||
#endif
|
||||
|
||||
@@ -100,26 +100,20 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template <typename Context, typename AliasProvider, typename Table, typename... ColumnSpec>
|
||||
struct serializer_t<Context, table_alias_t<AliasProvider, Table, ColumnSpec...>>
|
||||
Context& serialize(const table_alias_t<AliasProvider, Table, ColumnSpec...>& t, Context& context)
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, Table>;
|
||||
using T = table_alias_t<AliasProvider, Table, ColumnSpec...>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
if (requires_braces_t<Table>::value)
|
||||
{
|
||||
if (requires_braces_t<Table>::value)
|
||||
{
|
||||
context << "(";
|
||||
}
|
||||
serialize(t._table, context);
|
||||
if (requires_braces_t<Table>::value)
|
||||
{
|
||||
context << ")";
|
||||
}
|
||||
context << " AS " << name_of<T>::template char_ptr<Context>();
|
||||
return context;
|
||||
context << "(";
|
||||
}
|
||||
};
|
||||
serialize(t._table, context);
|
||||
if (requires_braces_t<Table>::value)
|
||||
{
|
||||
context << ")";
|
||||
}
|
||||
context << " AS " << name_of<table_alias_t<AliasProvider, Table, ColumnSpec...>>::template char_ptr<Context>();
|
||||
return context;
|
||||
}
|
||||
} // namespace sqlpp
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user