mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Finished replacing serializer_t
This commit is contained in:
parent
2cab1fa681
commit
68021772c2
@ -47,17 +47,9 @@ namespace sqlpp
|
|||||||
|
|
||||||
SQLPP_PORTABLE_STATIC_ASSERT(assert_no_stand_alone_all_of_t, "all_of(table) seems to be used outside of select");
|
SQLPP_PORTABLE_STATIC_ASSERT(assert_no_stand_alone_all_of_t, "all_of(table) seems to be used outside of select");
|
||||||
|
|
||||||
|
// FIXME: Do we need this?
|
||||||
template <typename Context, typename Table>
|
template <typename Context, typename Table>
|
||||||
struct serializer_t<Context, all_of_t<Table>>
|
Context& serialize(const all_of_t<Table>& t, Context& context);
|
||||||
{
|
|
||||||
using _serialize_check = assert_no_stand_alone_all_of_t;
|
|
||||||
using T = all_of_t<Table>;
|
|
||||||
|
|
||||||
static Context& _(const T& /*unused*/, const Context& /*unused*/)
|
|
||||||
{
|
|
||||||
_serialize_check{};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -53,19 +53,13 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename Select>
|
template <typename Context, typename Select>
|
||||||
struct serializer_t<Context, any_t<Select>>
|
Context& serialize(const any_t<Select>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Select>;
|
|
||||||
using T = any_t<Select>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
context << "ANY(";
|
context << "ANY(";
|
||||||
serialize(t._select, context);
|
serialize(t._select, context);
|
||||||
context << ")";
|
context << ")";
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto any(T t) -> any_t<wrap_operand_t<T>>
|
auto any(T t) -> any_t<wrap_operand_t<T>>
|
||||||
|
@ -62,19 +62,13 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename Lhs, typename Rhs>
|
template <typename Context, typename Lhs, typename Rhs>
|
||||||
struct serializer_t<Context, assignment_t<Lhs, Rhs>>
|
Context& serialize(const assignment_t<Lhs, Rhs>& t, Context& context)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
serialize(simple_column(t._lhs), context);
|
serialize(simple_column(t._lhs), context);
|
||||||
context << "=";
|
context << "=";
|
||||||
serialize_operand(t._rhs, context);
|
serialize_operand(t._rhs, context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,13 +46,7 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename ValueType>
|
template <typename Context, typename ValueType>
|
||||||
struct serializer_t<Context, bad_expression<ValueType>>
|
Context serialize(const bad_expression<ValueType>& t, Context& context);
|
||||||
{
|
|
||||||
using _serialize_check = assert_valid_operands;
|
|
||||||
using T = bad_expression<ValueType>;
|
|
||||||
|
|
||||||
static Context& _(const T&, Context&);
|
|
||||||
};
|
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -68,16 +68,10 @@ namespace sqlpp
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Context, typename Database>
|
template <typename Context, typename Database>
|
||||||
struct serializer_t<Context, boolean_expression_t<Database>>
|
Context& serialize(const boolean_expression_t<Database>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using T = boolean_expression_t<Database>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
return serialize(t._expr, context);
|
return serialize(t._expr, context);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -151,12 +151,7 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename When, typename Then, typename Else>
|
template <typename Context, typename When, typename Then, typename Else>
|
||||||
struct serializer_t<Context, case_t<When, Then, Else>>
|
Context& serialize(const case_t<When, Then, Else>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<When, Then, Else>;
|
|
||||||
using T = case_t<When, Then, Else>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
context << "(CASE WHEN ";
|
context << "(CASE WHEN ";
|
||||||
serialize(t._when, context);
|
serialize(t._when, context);
|
||||||
@ -167,7 +162,6 @@ namespace sqlpp
|
|||||||
context << " END)";
|
context << " END)";
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
@ -63,12 +63,7 @@ namespace sqlpp
|
|||||||
|
|
||||||
// Interpreters
|
// Interpreters
|
||||||
template <typename Context, typename Flag, typename Lhs, typename Rhs>
|
template <typename Context, typename Flag, typename Lhs, typename Rhs>
|
||||||
struct serializer_t<Context, cte_union_t<Flag, Lhs, Rhs>>
|
Context& serialize(const cte_union_t<Flag, Lhs, Rhs>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Lhs, Rhs>;
|
|
||||||
using T = cte_union_t<Flag, Lhs, Rhs>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
serialize(t._lhs, context);
|
serialize(t._lhs, context);
|
||||||
context << " UNION ";
|
context << " UNION ";
|
||||||
@ -77,7 +72,6 @@ namespace sqlpp
|
|||||||
serialize(t._rhs, context);
|
serialize(t._rhs, context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename AliasProvider, typename Statement, typename... FieldSpecs>
|
template <typename AliasProvider, typename Statement, typename... FieldSpecs>
|
||||||
struct cte_t;
|
struct cte_t;
|
||||||
@ -229,19 +223,14 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename AliasProvider, typename Statement, typename... ColumnSpecs>
|
template <typename Context, typename AliasProvider, typename Statement, typename... ColumnSpecs>
|
||||||
struct serializer_t<Context, cte_t<AliasProvider, Statement, ColumnSpecs...>>
|
Context& serialize(const cte_t<AliasProvider, Statement, ColumnSpecs...>& t, Context& context)
|
||||||
{
|
{
|
||||||
using _serialize_check = serialize_check_of<Context, Statement>;
|
|
||||||
using T = cte_t<AliasProvider, Statement, ColumnSpecs...>;
|
using T = cte_t<AliasProvider, Statement, ColumnSpecs...>;
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
|
||||||
context << name_of<T>::template char_ptr<Context>() << " AS (";
|
context << name_of<T>::template char_ptr<Context>() << " AS (";
|
||||||
serialize(t._statement, context);
|
serialize(t._statement, context);
|
||||||
context << ")";
|
context << ")";
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
// The cte_t is displayed as AliasProviderName except within the with:
|
// The cte_t is displayed as AliasProviderName except within the with:
|
||||||
// - the with needs the
|
// - the with needs the
|
||||||
@ -273,17 +262,11 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename AliasProvider>
|
template <typename Context, typename AliasProvider>
|
||||||
struct serializer_t<Context, cte_ref_t<AliasProvider>>
|
Context& serialize(const cte_ref_t<AliasProvider>&, Context& context)
|
||||||
{
|
{
|
||||||
using _serialize_check = consistent_t;
|
context << name_of<cte_ref_t<AliasProvider>>::template char_ptr<Context>();
|
||||||
using T = cte_ref_t<AliasProvider>;
|
|
||||||
|
|
||||||
static Context& _(const T& /*unused*/, Context& context)
|
|
||||||
{
|
|
||||||
context << name_of<T>::template char_ptr<Context>();
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename AliasProvider>
|
template <typename AliasProvider>
|
||||||
auto cte(const AliasProvider & /*unused*/) -> cte_ref_t<AliasProvider>
|
auto cte(const AliasProvider & /*unused*/) -> cte_ref_t<AliasProvider>
|
||||||
|
@ -123,17 +123,11 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename Database, typename... Parts>
|
template <typename Context, typename Database, typename... Parts>
|
||||||
struct serializer_t<Context, custom_query_t<Database, Parts...>>
|
Context serialize(const custom_query_t<Database, Parts...>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Parts...>;
|
|
||||||
using T = custom_query_t<Database, Parts...>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
interpret_tuple_without_braces(t._parts, " ", context);
|
interpret_tuple_without_braces(t._parts, " ", context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename... Parts>
|
template <typename... Parts>
|
||||||
auto custom_query(Parts... parts) -> custom_query_t<void, wrap_operand_t<Parts>...>
|
auto custom_query(Parts... parts) -> custom_query_t<void, wrap_operand_t<Parts>...>
|
||||||
|
@ -38,17 +38,11 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
struct serializer_t<Context, default_value_t>
|
Context& serialize(const default_value_t&, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using Operand = default_value_t;
|
|
||||||
|
|
||||||
static Context& _(const Operand& /*unused*/, Context& context)
|
|
||||||
{
|
{
|
||||||
context << "DEFAULT";
|
context << "DEFAULT";
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
constexpr default_value_t default_value = {};
|
constexpr default_value_t default_value = {};
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
@ -157,17 +157,11 @@ namespace sqlpp
|
|||||||
|
|
||||||
// Interpreters
|
// Interpreters
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
struct serializer_t<Context, for_update_data_t>
|
Context& serialize(const for_update_data_t&, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context>;
|
|
||||||
using T = for_update_data_t;
|
|
||||||
|
|
||||||
static Context& _(const T& /*unused*/, Context& context)
|
|
||||||
{
|
{
|
||||||
context << " FOR UPDATE ";
|
context << " FOR UPDATE ";
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto for_update(T&& t) -> decltype(statement_t<void, no_for_update_t>().for_update(std::forward<T>(t)))
|
auto for_update(T&& t) -> decltype(statement_t<void, no_for_update_t>().for_update(std::forward<T>(t)))
|
||||||
|
@ -85,8 +85,6 @@ namespace sqlpp
|
|||||||
assert_from_add_unique_names>,
|
assert_from_add_unique_names>,
|
||||||
static_check_t<detail::is_subset_of<_required_tables, _known_tables>::value,
|
static_check_t<detail::is_subset_of<_required_tables, _known_tables>::value,
|
||||||
assert_from_add_no_required_tables>
|
assert_from_add_no_required_tables>
|
||||||
// FIXME: Replace this with consistency check?
|
|
||||||
// sqlpp::serialize_check_t<serializer_context_of<typename From::_database_t>, DynamicJoin>
|
|
||||||
>;
|
>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -96,12 +96,7 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename Container>
|
template <typename Context, typename Container>
|
||||||
struct serializer_t<Context, value_list_t<Container>>
|
Context& serialize(const value_list_t<Container>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, wrap_operand_t<typename Container::value_type>>;
|
|
||||||
using T = value_list_t<Container>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
if (t._container.size() == 1)
|
if (t._container.size() == 1)
|
||||||
{
|
{
|
||||||
@ -124,7 +119,6 @@ namespace sqlpp
|
|||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Container>
|
template <typename Container>
|
||||||
auto value_list(Container c) -> value_list_t<Container>
|
auto value_list(Container c) -> value_list_t<Container>
|
||||||
|
@ -90,10 +90,7 @@ namespace sqlpp
|
|||||||
static_assert(is_expression_t<Expression>::value, "invalid expression argument in group_by::add()");
|
static_assert(is_expression_t<Expression>::value, "invalid expression argument in group_by::add()");
|
||||||
static_assert(Policies::template _no_unknown_tables<Expression>::value,
|
static_assert(Policies::template _no_unknown_tables<Expression>::value,
|
||||||
"expression uses tables unknown to this statement in group_by::add()");
|
"expression uses tables unknown to this statement in group_by::add()");
|
||||||
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Expression>;
|
using ok = logic::all_t<_is_dynamic::value, is_expression_t<Expression>::value>;
|
||||||
_serialize_check{};
|
|
||||||
|
|
||||||
using ok = logic::all_t<_is_dynamic::value, is_expression_t<Expression>::value, _serialize_check::type::value>;
|
|
||||||
|
|
||||||
_add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert
|
_add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert
|
||||||
}
|
}
|
||||||
|
@ -91,10 +91,7 @@ namespace sqlpp
|
|||||||
static_assert(is_expression_t<Expr>::value, "invalid expression argument in having::add()");
|
static_assert(is_expression_t<Expr>::value, "invalid expression argument in having::add()");
|
||||||
static_assert(Policies::template _no_unknown_tables<Expr>::value,
|
static_assert(Policies::template _no_unknown_tables<Expr>::value,
|
||||||
"expression uses tables unknown to this statement in having::add()");
|
"expression uses tables unknown to this statement in having::add()");
|
||||||
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Expr>;
|
using ok = logic::all_t<_is_dynamic::value, is_expression_t<Expr>::value>;
|
||||||
_serialize_check{};
|
|
||||||
|
|
||||||
using ok = logic::all_t<_is_dynamic::value, is_expression_t<Expr>::value, _serialize_check::type::value>;
|
|
||||||
|
|
||||||
_add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert
|
_add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert
|
||||||
}
|
}
|
||||||
@ -292,12 +289,7 @@ namespace sqlpp
|
|||||||
|
|
||||||
// Interpreters
|
// Interpreters
|
||||||
template <typename Context, typename Database, typename Expression>
|
template <typename Context, typename Database, typename Expression>
|
||||||
struct serializer_t<Context, having_data_t<Database, Expression>>
|
Context& serialize(const having_data_t<Database, Expression>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Expression>;
|
|
||||||
using T = having_data_t<Database, Expression>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
context << " HAVING ";
|
context << " HAVING ";
|
||||||
serialize(t._expression, context);
|
serialize(t._expression, context);
|
||||||
@ -308,7 +300,6 @@ namespace sqlpp
|
|||||||
interpret_list(t._dynamic_expressions, " AND ", context);
|
interpret_list(t._dynamic_expressions, " AND ", context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto having(T&& t) -> decltype(statement_t<void, no_having_t>().having(std::forward<T>(t)))
|
auto having(T&& t) -> decltype(statement_t<void, no_having_t>().having(std::forward<T>(t)))
|
||||||
|
@ -46,16 +46,10 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename Clause>
|
template <typename Context, typename Clause>
|
||||||
struct serializer_t<Context, hidden_t<Clause>>
|
Context& serialize(const hidden_t<Clause>&, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using T = hidden_t<Clause>;
|
|
||||||
|
|
||||||
static Context& _(const T& /*unused*/, Context& context)
|
|
||||||
{
|
{
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Clause>
|
template <typename Clause>
|
||||||
auto hidden(Clause part) -> hidden_t<Clause>
|
auto hidden(Clause part) -> hidden_t<Clause>
|
||||||
|
@ -73,12 +73,7 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename Operand, typename... Args>
|
template <typename Context, typename Operand, typename... Args>
|
||||||
struct serializer_t<Context, in_t<Operand, Args...>>
|
Context& serialize(const in_t<Operand, Args...>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Args...>;
|
|
||||||
using T = in_t<Operand, Args...>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
serialize(t._operand, context);
|
serialize(t._operand, context);
|
||||||
context << " IN(";
|
context << " IN(";
|
||||||
@ -93,31 +88,19 @@ namespace sqlpp
|
|||||||
context << ')';
|
context << ')';
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Context, typename Operand>
|
template <typename Context, typename Operand>
|
||||||
struct serializer_t<Context, in_t<Operand>>
|
Context& serialize(const in_t<Operand>&, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using T = in_t<Operand>;
|
|
||||||
|
|
||||||
static Context& _(const T& /*unused*/, Context& context)
|
|
||||||
{
|
{
|
||||||
serialize(boolean_operand{false}, context);
|
serialize(boolean_operand{false}, context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Container>
|
template <typename Container>
|
||||||
struct value_list_t;
|
struct value_list_t;
|
||||||
|
|
||||||
template <typename Context, typename Operand, typename Container>
|
template <typename Context, typename Operand, typename Container>
|
||||||
struct serializer_t<Context, in_t<Operand, value_list_t<Container>>>
|
Context& serialize(const in_t<Operand, value_list_t<Container>>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, value_list_t<Container>>;
|
|
||||||
using T = in_t<Operand, value_list_t<Container>>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
const auto& value_list = std::get<0>(t._args);
|
const auto& value_list = std::get<0>(t._args);
|
||||||
if (value_list._container.empty())
|
if (value_list._container.empty())
|
||||||
@ -133,7 +116,6 @@ namespace sqlpp
|
|||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -89,18 +89,12 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
struct serializer_t<Context, insert_name_t>
|
Context& serialize(const insert_name_t&, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using T = insert_name_t;
|
|
||||||
|
|
||||||
static Context& _(const T& /*unused*/, Context& context)
|
|
||||||
{
|
{
|
||||||
context << "INSERT";
|
context << "INSERT";
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Database>
|
template <typename Database>
|
||||||
using blank_insert_t = statement_t<Database, insert_t, no_into_t, no_insert_value_list_t>;
|
using blank_insert_t = statement_t<Database, insert_t, no_into_t, no_insert_value_list_t>;
|
||||||
|
@ -96,12 +96,7 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename ValueType>
|
template <typename Context, typename ValueType>
|
||||||
struct serializer_t<Context, insert_value_t<ValueType>>
|
Context& serialize(const insert_value_t<ValueType>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, ValueType>;
|
|
||||||
using T = insert_value_t<ValueType>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
if (t._is_null)
|
if (t._is_null)
|
||||||
{
|
{
|
||||||
@ -117,7 +112,6 @@ namespace sqlpp
|
|||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -290,10 +290,7 @@ namespace sqlpp
|
|||||||
static_assert(not must_not_insert_t<lhs_t<Assignment>>::value, "add() argument must not be used in insert");
|
static_assert(not must_not_insert_t<lhs_t<Assignment>>::value, "add() argument must not be used in insert");
|
||||||
static_assert(Policies::template _no_unknown_tables<Assignment>::value,
|
static_assert(Policies::template _no_unknown_tables<Assignment>::value,
|
||||||
"add() contains a column from a foreign table");
|
"add() contains a column from a foreign table");
|
||||||
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Assignment>;
|
using ok = logic::all_t<_is_dynamic::value, is_assignment_t<Assignment>::value>;
|
||||||
_serialize_check{};
|
|
||||||
|
|
||||||
using ok = logic::all_t<_is_dynamic::value, is_assignment_t<Assignment>::value, _serialize_check::type::value>;
|
|
||||||
|
|
||||||
_add_impl(assignment, ok()); // dispatch to prevent compile messages after the static_assert
|
_add_impl(assignment, ok()); // dispatch to prevent compile messages after the static_assert
|
||||||
}
|
}
|
||||||
@ -604,25 +601,15 @@ namespace sqlpp
|
|||||||
|
|
||||||
// Interpreters
|
// Interpreters
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
struct serializer_t<Context, insert_default_values_data_t>
|
Context& serialize(const insert_default_values_data_t&, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using T = insert_default_values_data_t;
|
|
||||||
|
|
||||||
static Context& _(const T& /*unused*/, Context& context)
|
|
||||||
{
|
{
|
||||||
context << " DEFAULT VALUES";
|
context << " DEFAULT VALUES";
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Context, typename... Columns>
|
template <typename Context, typename... Columns>
|
||||||
struct serializer_t<Context, column_list_data_t<Columns...>>
|
Context& serialize(const column_list_data_t<Columns...>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Columns...>;
|
|
||||||
using T = column_list_data_t<Columns...>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
context << " (";
|
context << " (";
|
||||||
interpret_tuple(t._columns, ",", context);
|
interpret_tuple(t._columns, ",", context);
|
||||||
@ -646,15 +633,9 @@ namespace sqlpp
|
|||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Context, typename Database, typename... Assignments>
|
template <typename Context, typename Database, typename... Assignments>
|
||||||
struct serializer_t<Context, insert_list_data_t<Database, Assignments...>>
|
Context& serialize(const insert_list_data_t<Database, Assignments...>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Assignments...>;
|
|
||||||
using T = insert_list_data_t<Database, Assignments...>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
if (sizeof...(Assignments) + t._dynamic_columns.size() == 0)
|
if (sizeof...(Assignments) + t._dynamic_columns.size() == 0)
|
||||||
{
|
{
|
||||||
@ -684,7 +665,6 @@ namespace sqlpp
|
|||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename... Assignments>
|
template <typename... Assignments>
|
||||||
auto insert_set(Assignments... assignments)
|
auto insert_set(Assignments... assignments)
|
||||||
|
@ -192,18 +192,12 @@ namespace sqlpp
|
|||||||
|
|
||||||
// Interpreters
|
// Interpreters
|
||||||
template <typename Context, typename Database, typename Table>
|
template <typename Context, typename Database, typename Table>
|
||||||
struct serializer_t<Context, into_data_t<Database, Table>>
|
Context& serialize(const into_data_t<Database, Table>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Table>;
|
|
||||||
using T = into_data_t<Database, Table>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
context << " INTO ";
|
context << " INTO ";
|
||||||
serialize(t._table, context);
|
serialize(t._table, context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto into(T&& t) -> decltype(statement_t<void, no_into_t>().into(std::forward<T>(t)))
|
auto into(T&& t) -> decltype(statement_t<void, no_into_t>().into(std::forward<T>(t)))
|
||||||
|
@ -54,12 +54,7 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename Expr, typename ValueType>
|
template <typename Context, typename Expr, typename ValueType>
|
||||||
struct serializer_t<Context, is_equal_to_or_null_t<Expr, ValueType>>
|
Context& serialize(const is_equal_to_or_null_t<Expr, ValueType>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using Operand = is_equal_to_or_null_t<Expr, ValueType>;
|
|
||||||
|
|
||||||
static Context& _(const Operand& t, Context& context)
|
|
||||||
{
|
{
|
||||||
if (t._value._is_null)
|
if (t._value._is_null)
|
||||||
serialize(t._expr.is_null(), context);
|
serialize(t._expr.is_null(), context);
|
||||||
@ -68,7 +63,6 @@ namespace sqlpp
|
|||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Expr, typename ValueType>
|
template <typename Expr, typename ValueType>
|
||||||
auto is_equal_to_or_null(Expr expr, value_or_null_t<ValueType> value) -> is_equal_to_or_null_t<Expr, ValueType>
|
auto is_equal_to_or_null(Expr expr, value_or_null_t<ValueType> value) -> is_equal_to_or_null_t<Expr, ValueType>
|
||||||
|
@ -287,12 +287,7 @@ namespace sqlpp
|
|||||||
|
|
||||||
// Interpreters
|
// Interpreters
|
||||||
template <typename Context, typename Database>
|
template <typename Context, typename Database>
|
||||||
struct serializer_t<Context, dynamic_limit_data_t<Database>>
|
Context& serialize(const dynamic_limit_data_t<Database>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using T = dynamic_limit_data_t<Database>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
if (t._initialized)
|
if (t._initialized)
|
||||||
{
|
{
|
||||||
@ -301,21 +296,14 @@ namespace sqlpp
|
|||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Context, typename Limit>
|
template <typename Context, typename Limit>
|
||||||
struct serializer_t<Context, limit_data_t<Limit>>
|
Context& serialize(const limit_data_t<Limit>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Limit>;
|
|
||||||
using T = limit_data_t<Limit>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
context << " LIMIT ";
|
context << " LIMIT ";
|
||||||
serialize_operand(t._value, context);
|
serialize_operand(t._value, context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto limit(T&& t) -> decltype(statement_t<void, no_limit_t>().limit(std::forward<T>(t)))
|
auto limit(T&& t) -> decltype(statement_t<void, no_limit_t>().limit(std::forward<T>(t)))
|
||||||
|
@ -79,7 +79,7 @@ namespace sqlpp
|
|||||||
|
|
||||||
_serializer_context_t& interpret(_serializer_context_t& context) const
|
_serializer_context_t& interpret(_serializer_context_t& context) const
|
||||||
{
|
{
|
||||||
interpret(_t, context);
|
serialize(_t, context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,17 +38,11 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
struct serializer_t<Context, null_t>
|
Context& serialize(const null_t&, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using Operand = null_t;
|
|
||||||
|
|
||||||
static Context& _(const Operand& /*unused*/, Context& context)
|
|
||||||
{
|
{
|
||||||
context << "NULL";
|
context << "NULL";
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
constexpr null_t null = {};
|
constexpr null_t null = {};
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
@ -301,26 +301,15 @@ namespace sqlpp
|
|||||||
|
|
||||||
// Interpreters
|
// Interpreters
|
||||||
template <typename Context, typename Offset>
|
template <typename Context, typename Offset>
|
||||||
struct serializer_t<Context, offset_data_t<Offset>>
|
Context& serialize(const offset_data_t<Offset>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Offset>;
|
|
||||||
using T = offset_data_t<Offset>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
context << " OFFSET ";
|
context << " OFFSET ";
|
||||||
serialize_operand(t._value, context);
|
serialize_operand(t._value, context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Context, typename Database>
|
template <typename Context, typename Database>
|
||||||
struct serializer_t<Context, dynamic_offset_data_t<Database>>
|
Context& serialize(const dynamic_offset_data_t<Database>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using T = dynamic_offset_data_t<Database>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
if (t._initialized)
|
if (t._initialized)
|
||||||
{
|
{
|
||||||
@ -329,7 +318,6 @@ namespace sqlpp
|
|||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto offset(T&& t) -> decltype(statement_t<void, no_offset_t>().offset(std::forward<T>(t)))
|
auto offset(T&& t) -> decltype(statement_t<void, no_offset_t>().offset(std::forward<T>(t)))
|
||||||
|
@ -88,10 +88,7 @@ namespace sqlpp
|
|||||||
static_assert(is_sort_order_t<Expression>::value, "invalid expression argument in order_by::add()");
|
static_assert(is_sort_order_t<Expression>::value, "invalid expression argument in order_by::add()");
|
||||||
static_assert(Policies::template _no_unknown_tables<Expression>::value,
|
static_assert(Policies::template _no_unknown_tables<Expression>::value,
|
||||||
"expression uses tables unknown to this statement in order_by::add()");
|
"expression uses tables unknown to this statement in order_by::add()");
|
||||||
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Expression>;
|
using ok = logic::all_t<_is_dynamic::value, is_sort_order_t<Expression>::value>;
|
||||||
_serialize_check{};
|
|
||||||
|
|
||||||
using ok = logic::all_t<_is_dynamic::value, is_sort_order_t<Expression>::value, _serialize_check::type::value>;
|
|
||||||
|
|
||||||
_add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert
|
_add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert
|
||||||
}
|
}
|
||||||
@ -250,12 +247,7 @@ namespace sqlpp
|
|||||||
|
|
||||||
// Interpreters
|
// Interpreters
|
||||||
template <typename Context, typename Database, typename... Expressions>
|
template <typename Context, typename Database, typename... Expressions>
|
||||||
struct serializer_t<Context, order_by_data_t<Database, Expressions...>>
|
Context& serialize(const order_by_data_t<Database, Expressions...>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Expressions...>;
|
|
||||||
using T = order_by_data_t<Database, Expressions...>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
if (sizeof...(Expressions) == 0 and t._dynamic_expressions.empty())
|
if (sizeof...(Expressions) == 0 and t._dynamic_expressions.empty())
|
||||||
{
|
{
|
||||||
@ -270,7 +262,6 @@ namespace sqlpp
|
|||||||
interpret_list(t._dynamic_expressions, ',', context);
|
interpret_list(t._dynamic_expressions, ',', context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
auto order_by(T&&... t) -> decltype(statement_t<void, no_order_by_t>().order_by(std::forward<T>(t)...))
|
auto order_by(T&&... t) -> decltype(statement_t<void, no_order_by_t>().order_by(std::forward<T>(t)...))
|
||||||
|
@ -56,18 +56,12 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename AggregateExpr>
|
template <typename Context, typename AggregateExpr>
|
||||||
struct serializer_t<Context, over_t<AggregateExpr>>
|
Context& serialize(const over_t<AggregateExpr>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, AggregateExpr>;
|
|
||||||
using T = over_t<AggregateExpr>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
serialize_operand(t._aggregate_expression, context);
|
serialize_operand(t._aggregate_expression, context);
|
||||||
context << " OVER()";
|
context << " OVER()";
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -57,17 +57,11 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename ValueType, typename NameType>
|
template <typename Context, typename ValueType, typename NameType>
|
||||||
struct serializer_t<Context, parameter_t<ValueType, NameType>>
|
Context& serialize(const parameter_t<ValueType, NameType>&, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using T = parameter_t<ValueType, NameType>;
|
|
||||||
|
|
||||||
static Context& _(const T& /*unused*/, Context& context)
|
|
||||||
{
|
{
|
||||||
context << "?";
|
context << "?";
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename NamedExpr>
|
template <typename NamedExpr>
|
||||||
auto parameter(const NamedExpr & /*unused*/) -> parameter_t<value_type_of<NamedExpr>, NamedExpr>
|
auto parameter(const NamedExpr & /*unused*/) -> parameter_t<value_type_of<NamedExpr>, NamedExpr>
|
||||||
|
@ -59,19 +59,13 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename ValueType, typename Expr>
|
template <typename Context, typename ValueType, typename Expr>
|
||||||
struct serializer_t<Context, parameterized_verbatim_t<ValueType, Expr>>
|
Context& serialize(const parameterized_verbatim_t<ValueType, Expr>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using T = parameterized_verbatim_t<ValueType, Expr>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
context << t._verbatim_lhs;
|
context << t._verbatim_lhs;
|
||||||
serialize(t._expr, context);
|
serialize(t._expr, context);
|
||||||
context << t._verbatim_rhs;
|
context << t._verbatim_rhs;
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename ValueType, typename Expr>
|
template <typename ValueType, typename Expr>
|
||||||
auto parameterized_verbatim(std::string lhs, Expr expr, std::string rhs)
|
auto parameterized_verbatim(std::string lhs, Expr expr, std::string rhs)
|
||||||
|
@ -88,18 +88,12 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
struct serializer_t<Context, remove_name_t>
|
Context& serialize(const remove_name_t&, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using T = remove_name_t;
|
|
||||||
|
|
||||||
static Context& _(const T& /*unused*/, Context& context)
|
|
||||||
{
|
{
|
||||||
context << "DELETE";
|
context << "DELETE";
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Database>
|
template <typename Database>
|
||||||
using blank_remove_t = statement_t<Database, remove_t, no_from_t, no_using_t, no_where_t<true>>;
|
using blank_remove_t = statement_t<Database, remove_t, no_from_t, no_using_t, no_where_t<true>>;
|
||||||
|
@ -42,12 +42,7 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename Db, typename FieldSpec>
|
template <typename Context, typename Db, typename FieldSpec>
|
||||||
struct serializer_t<Context, result_field_t<Db, FieldSpec>>
|
Context& serialize(const result_field_t<Db, FieldSpec>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using T = result_field_t<Db, FieldSpec>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
if (t.is_null())
|
if (t.is_null())
|
||||||
{
|
{
|
||||||
@ -59,7 +54,6 @@ namespace sqlpp
|
|||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Db, typename FieldSpec>
|
template <typename Db, typename FieldSpec>
|
||||||
inline std::ostream& operator<<(std::ostream& os, const result_field_t<Db, FieldSpec>& rf)
|
inline std::ostream& operator<<(std::ostream& os, const result_field_t<Db, FieldSpec>& rf)
|
||||||
|
@ -40,17 +40,11 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
struct serializer_t<Context, schema_t>
|
Context& serialize(const schema_t& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using T = schema_t;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
context << t._name;
|
context << t._name;
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -63,19 +63,13 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename Table>
|
template <typename Context, typename Table>
|
||||||
struct serializer_t<Context, schema_qualified_table_t<Table>>
|
Context& serialize(const schema_qualified_table_t<Table>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Table>;
|
|
||||||
using T = schema_qualified_table_t<Table>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
serialize(t._schema, context);
|
serialize(t._schema, context);
|
||||||
context << '.';
|
context << '.';
|
||||||
serialize(t._table, context);
|
serialize(t._table, context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Table>
|
template <typename Table>
|
||||||
auto schema_qualified_table(schema_t schema, Table table) -> schema_qualified_table_t<Table>
|
auto schema_qualified_table(schema_t schema, Table table) -> schema_qualified_table_t<Table>
|
||||||
|
@ -84,10 +84,7 @@ namespace sqlpp
|
|||||||
static_assert(is_select_flag_t<Flag>::value, "invalid select flag argument in select_flags::add()");
|
static_assert(is_select_flag_t<Flag>::value, "invalid select flag argument in select_flags::add()");
|
||||||
static_assert(Policies::template _no_unknown_tables<Flag>::value,
|
static_assert(Policies::template _no_unknown_tables<Flag>::value,
|
||||||
"flag uses tables unknown to this statement in select_flags::add()");
|
"flag uses tables unknown to this statement in select_flags::add()");
|
||||||
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Flag>;
|
using ok = logic::all_t<_is_dynamic::value, is_select_flag_t<Flag>::value>;
|
||||||
_serialize_check{};
|
|
||||||
|
|
||||||
using ok = logic::all_t<_is_dynamic::value, is_select_flag_t<Flag>::value, _serialize_check::type::value>;
|
|
||||||
|
|
||||||
_add_impl(flag, ok()); // dispatch to prevent compile messages after the static_assert
|
_add_impl(flag, ok()); // dispatch to prevent compile messages after the static_assert
|
||||||
}
|
}
|
||||||
@ -240,12 +237,7 @@ namespace sqlpp
|
|||||||
|
|
||||||
// Interpreters
|
// Interpreters
|
||||||
template <typename Context, typename Database, typename... Flags>
|
template <typename Context, typename Database, typename... Flags>
|
||||||
struct serializer_t<Context, select_flag_list_data_t<Database, Flags...>>
|
Context& serialize(const select_flag_list_data_t<Database, Flags...>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Flags...>;
|
|
||||||
using T = select_flag_list_data_t<Database, Flags...>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
interpret_tuple(t._flags, ' ', context);
|
interpret_tuple(t._flags, ' ', context);
|
||||||
if (sizeof...(Flags) != 0u)
|
if (sizeof...(Flags) != 0u)
|
||||||
@ -259,7 +251,6 @@ namespace sqlpp
|
|||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto select_flags(T&& t) -> decltype(statement_t<void, no_select_flag_list_t>().flags(std::forward<T>(t)))
|
auto select_flags(T&& t) -> decltype(statement_t<void, no_select_flag_list_t>().flags(std::forward<T>(t)))
|
||||||
|
@ -43,16 +43,11 @@ namespace sqlpp
|
|||||||
static constexpr all_t all = {};
|
static constexpr all_t all = {};
|
||||||
|
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
struct serializer_t<Context, all_t>
|
Context& serialize(const all_t&, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
|
|
||||||
static Context& _(const all_t& /*unused*/, Context& context)
|
|
||||||
{
|
{
|
||||||
context << "ALL";
|
context << "ALL";
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
struct distinct_t
|
struct distinct_t
|
||||||
{
|
{
|
||||||
@ -62,16 +57,11 @@ namespace sqlpp
|
|||||||
static constexpr distinct_t distinct = {};
|
static constexpr distinct_t distinct = {};
|
||||||
|
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
struct serializer_t<Context, distinct_t>
|
Context& serialize(const distinct_t&, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
|
|
||||||
static Context& _(const distinct_t& /*unused*/, Context& context)
|
|
||||||
{
|
{
|
||||||
context << "DISTINCT";
|
context << "DISTINCT";
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
struct straight_join_t
|
struct straight_join_t
|
||||||
{
|
{
|
||||||
@ -81,16 +71,11 @@ namespace sqlpp
|
|||||||
static constexpr straight_join_t straight_join = {};
|
static constexpr straight_join_t straight_join = {};
|
||||||
|
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
struct serializer_t<Context, straight_join_t>
|
Context& serialize(const straight_join_t&, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
|
|
||||||
static Context& _(const straight_join_t& /*unused*/, Context& context)
|
|
||||||
{
|
{
|
||||||
context << "STRAIGHT_JOIN";
|
context << "STRAIGHT_JOIN";
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,29 +27,16 @@
|
|||||||
#ifndef SQLPP11_SERIALIZER_H
|
#ifndef SQLPP11_SERIALIZER_H
|
||||||
#define SQLPP11_SERIALIZER_H
|
#define SQLPP11_SERIALIZER_H
|
||||||
|
|
||||||
#include <sqlpp11/portable_static_assert.h>
|
#include <type_traits>
|
||||||
#include <sqlpp11/wrong.h>
|
|
||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
SQLPP_PORTABLE_STATIC_ASSERT(assert_serializer_specialization_t, "missing serializer specialization");
|
// FIXME: Move to type_traits.h, for instance
|
||||||
|
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
std::integral_constant<char, '"'> get_quote_left(const Context&);
|
std::integral_constant<char, '"'> get_quote_left(const Context&);
|
||||||
|
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
std::integral_constant<char, '"'> get_quote_right(const Context&);
|
std::integral_constant<char, '"'> get_quote_right(const Context&);
|
||||||
|
|
||||||
template <typename Context, typename T, typename Enable = void>
|
|
||||||
struct serializer_t
|
|
||||||
{
|
|
||||||
using _serialize_check = assert_serializer_specialization_t;
|
|
||||||
|
|
||||||
static void _(const T& t, Context& /*unused*/)
|
|
||||||
{
|
|
||||||
_serialize_check{t};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -49,17 +49,11 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename Column>
|
template <typename Context, typename Column>
|
||||||
struct serializer_t<Context, simple_column_t<Column>>
|
Context& serialize(const simple_column_t<Column>&, Context& context)
|
||||||
{
|
{
|
||||||
using _serialize_check = serialize_check_of<Context, Column>;
|
context << name_of<typename simple_column_t<Column>::_column_t>::template char_ptr<Context>();
|
||||||
using T = simple_column_t<Column>;
|
|
||||||
|
|
||||||
static Context& _(const T& /*unused*/, Context& context)
|
|
||||||
{
|
|
||||||
context << name_of<typename T::_column_t>::template char_ptr<Context>();
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Column>
|
template <typename Column>
|
||||||
simple_column_t<Column> simple_column(Column c)
|
simple_column_t<Column> simple_column(Column c)
|
||||||
|
@ -192,17 +192,11 @@ namespace sqlpp
|
|||||||
|
|
||||||
// Interpreters
|
// Interpreters
|
||||||
template <typename Context, typename Database, typename Table>
|
template <typename Context, typename Database, typename Table>
|
||||||
struct serializer_t<Context, single_table_data_t<Database, Table>>
|
Context& serialize(const single_table_data_t<Database, Table>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Table>;
|
|
||||||
using T = single_table_data_t<Database, Table>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
serialize(t._table, context);
|
serialize(t._table, context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -53,19 +53,13 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename Select>
|
template <typename Context, typename Select>
|
||||||
struct serializer_t<Context, some_t<Select>>
|
Context& serialize(const some_t<Select>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Select>;
|
|
||||||
using T = some_t<Select>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
context << "SOME(";
|
context << "SOME(";
|
||||||
serialize(t._select, context);
|
serialize(t._select, context);
|
||||||
context << ")";
|
context << ")";
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto some(T t) -> some_t<wrap_operand_t<T>>
|
auto some(T t) -> some_t<wrap_operand_t<T>>
|
||||||
|
@ -50,12 +50,7 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename Expression>
|
template <typename Context, typename Expression>
|
||||||
struct serializer_t<Context, sort_order_t<Expression>>
|
Context& serialize(const sort_order_t<Expression>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Expression>;
|
|
||||||
using T = sort_order_t<Expression>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
serialize_operand(t._expression, context);
|
serialize_operand(t._expression, context);
|
||||||
switch (t._sort_type)
|
switch (t._sort_type)
|
||||||
@ -69,7 +64,6 @@ namespace sqlpp
|
|||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -81,19 +81,13 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename Flag, typename Expr>
|
template <typename Context, typename Flag, typename Expr>
|
||||||
struct serializer_t<Context, trim_t<Flag, Expr>>
|
Context& serialize(const trim_t<Flag, Expr>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Flag, Expr>;
|
|
||||||
using T = trim_t<Flag, Expr>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
context << "TRIM(";
|
context << "TRIM(";
|
||||||
serialize(t._expr, context);
|
serialize(t._expr, context);
|
||||||
context << ")";
|
context << ")";
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto trim(T t) -> trim_t<noop, wrap_operand_t<T>>
|
auto trim(T t) -> trim_t<noop, wrap_operand_t<T>>
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <sqlpp11/consistent.h>
|
#include <sqlpp11/consistent.h>
|
||||||
|
#include <sqlpp11/portable_static_assert.h>
|
||||||
#include <sqlpp11/serializer.h>
|
#include <sqlpp11/serializer.h>
|
||||||
#include <sqlpp11/detail/type_vector.h>
|
#include <sqlpp11/detail/type_vector.h>
|
||||||
#include <sqlpp11/detail/type_set.h>
|
#include <sqlpp11/detail/type_set.h>
|
||||||
@ -391,10 +392,6 @@ namespace sqlpp
|
|||||||
using is_inconsistent_t =
|
using is_inconsistent_t =
|
||||||
typename std::conditional<std::is_same<consistent_t, T>::value, std::false_type, std::true_type>::type;
|
typename std::conditional<std::is_same<consistent_t, T>::value, std::false_type, std::true_type>::type;
|
||||||
|
|
||||||
template <typename Context, typename... T>
|
|
||||||
using serialize_check_of =
|
|
||||||
detail::get_first_if<is_inconsistent_t, consistent_t, typename serializer_t<Context, T>::_serialize_check...>;
|
|
||||||
|
|
||||||
SQLPP_PORTABLE_STATIC_ASSERT(assert_sqlpp_type_t, "expression is not an sqlpp type, consistency cannot be verified");
|
SQLPP_PORTABLE_STATIC_ASSERT(assert_sqlpp_type_t, "expression is not an sqlpp type, consistency cannot be verified");
|
||||||
SQLPP_PORTABLE_STATIC_ASSERT(assert_run_statement_or_prepared_t,
|
SQLPP_PORTABLE_STATIC_ASSERT(assert_run_statement_or_prepared_t,
|
||||||
"connection cannot run something that is neither statement nor prepared statement");
|
"connection cannot run something that is neither statement nor prepared statement");
|
||||||
@ -416,21 +413,6 @@ namespace sqlpp
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
using consistency_check_t = typename consistency_check<T>::type;
|
using consistency_check_t = typename consistency_check<T>::type;
|
||||||
|
|
||||||
template <typename Context, typename T, typename Enable = void>
|
|
||||||
struct serialize_check
|
|
||||||
{
|
|
||||||
using type = serialize_check_of<Context, T>;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Context, typename T>
|
|
||||||
struct serialize_check<Context, T, typename std::enable_if<is_prepared_statement_t<T>::value>::type>
|
|
||||||
{
|
|
||||||
using type = consistent_t; // this is already serialized
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Context, typename T>
|
|
||||||
using serialize_check_t = typename serialize_check<Context, T>::type;
|
|
||||||
|
|
||||||
template <typename Context, typename T, typename Enable = void>
|
template <typename Context, typename T, typename Enable = void>
|
||||||
struct run_check
|
struct run_check
|
||||||
{
|
{
|
||||||
@ -459,7 +441,7 @@ namespace sqlpp
|
|||||||
struct prepare_check<Context, T, typename std::enable_if<is_statement_t<T>::value>::type>
|
struct prepare_check<Context, T, typename std::enable_if<is_statement_t<T>::value>::type>
|
||||||
{
|
{
|
||||||
using type = detail::
|
using type = detail::
|
||||||
get_first_if<is_inconsistent_t, consistent_t, typename T::_prepare_check, serialize_check_t<Context, T>>;
|
get_first_if<is_inconsistent_t, consistent_t, typename T::_prepare_check>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename T>
|
template <typename Context, typename T>
|
||||||
|
@ -50,12 +50,7 @@ namespace sqlpp
|
|||||||
|
|
||||||
// Interpreters
|
// Interpreters
|
||||||
template <typename Context, typename Database, typename Flag, typename Lhs, typename Rhs>
|
template <typename Context, typename Database, typename Flag, typename Lhs, typename Rhs>
|
||||||
struct serializer_t<Context, union_data_t<Database, Flag, Lhs, Rhs>>
|
Context& serialize(const union_data_t<Database, Flag, Lhs, Rhs>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Lhs, Rhs>;
|
|
||||||
using T = union_data_t<Database, Flag, Lhs, Rhs>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
serialize(t._lhs, context);
|
serialize(t._lhs, context);
|
||||||
context << " UNION ";
|
context << " UNION ";
|
||||||
@ -64,7 +59,6 @@ namespace sqlpp
|
|||||||
serialize(t._rhs, context);
|
serialize(t._rhs, context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,16 +42,11 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
struct serializer_t<Context, union_all_t>
|
Context& serialize(const union_all_t&, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
|
|
||||||
static Context& _(const union_all_t& /*unused*/, Context& context)
|
|
||||||
{
|
{
|
||||||
context << "ALL";
|
context << "ALL";
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
struct union_distinct_t
|
struct union_distinct_t
|
||||||
{
|
{
|
||||||
@ -60,15 +55,10 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
struct serializer_t<Context, union_distinct_t>
|
Context& serialize(const union_distinct_t&, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
|
|
||||||
static Context& _(const union_distinct_t& /*unused*/, Context& context)
|
|
||||||
{
|
{
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -89,18 +89,11 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
struct serializer_t<Context, update_name_t>
|
Context& serialize(const update_name_t&, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using T = update_name_t;
|
|
||||||
|
|
||||||
static Context& _(const T& /*unused*/, Context& context)
|
|
||||||
{
|
{
|
||||||
context << "UPDATE ";
|
context << "UPDATE ";
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Database>
|
template <typename Database>
|
||||||
using blank_update_t = statement_t<Database, update_t, no_single_table_t, no_update_list_t, no_where_t<true>>;
|
using blank_update_t = statement_t<Database, update_t, no_single_table_t, no_update_list_t, no_where_t<true>>;
|
||||||
|
@ -88,10 +88,7 @@ namespace sqlpp
|
|||||||
static_assert(logic::not_t<must_not_update_t, lhs_t<Assignment>>::value, "add() argument must not be updated");
|
static_assert(logic::not_t<must_not_update_t, lhs_t<Assignment>>::value, "add() argument must not be updated");
|
||||||
static_assert(Policies::template _no_unknown_tables<Assignment>::value,
|
static_assert(Policies::template _no_unknown_tables<Assignment>::value,
|
||||||
"assignment uses tables unknown to this statement in add()");
|
"assignment uses tables unknown to this statement in add()");
|
||||||
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Assignment>;
|
using ok = logic::all_t<_is_dynamic::value, is_assignment_t<Assignment>::value>;
|
||||||
_serialize_check{};
|
|
||||||
|
|
||||||
using ok = logic::all_t<_is_dynamic::value, is_assignment_t<Assignment>::value, _serialize_check::type::value>;
|
|
||||||
|
|
||||||
_add_impl(assignment, ok()); // dispatch to prevent compile messages after the static_assert
|
_add_impl(assignment, ok()); // dispatch to prevent compile messages after the static_assert
|
||||||
}
|
}
|
||||||
@ -294,12 +291,7 @@ namespace sqlpp
|
|||||||
|
|
||||||
// Interpreters
|
// Interpreters
|
||||||
template <typename Context, typename Database, typename... Assignments>
|
template <typename Context, typename Database, typename... Assignments>
|
||||||
struct serializer_t<Context, update_list_data_t<Database, Assignments...>>
|
Context& serialize(const update_list_data_t<Database, Assignments...>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Assignments...>;
|
|
||||||
using T = update_list_data_t<Database, Assignments...>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
context << " SET ";
|
context << " SET ";
|
||||||
interpret_tuple(t._assignments, ",", context);
|
interpret_tuple(t._assignments, ",", context);
|
||||||
@ -310,7 +302,6 @@ namespace sqlpp
|
|||||||
interpret_list(t._dynamic_assignments, ',', context);
|
interpret_list(t._dynamic_assignments, ',', context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -80,10 +80,7 @@ namespace sqlpp
|
|||||||
{
|
{
|
||||||
static_assert(_is_dynamic::value, "add must not be called for static using()");
|
static_assert(_is_dynamic::value, "add must not be called for static using()");
|
||||||
static_assert(is_table_t<Table>::value, "invalid table argument in add()");
|
static_assert(is_table_t<Table>::value, "invalid table argument in add()");
|
||||||
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Table>;
|
using ok = logic::all_t<_is_dynamic::value, is_table_t<Table>::value>;
|
||||||
_serialize_check{};
|
|
||||||
|
|
||||||
using ok = logic::all_t<_is_dynamic::value, is_table_t<Table>::value, _serialize_check::type::value>;
|
|
||||||
|
|
||||||
_add_impl(table, ok()); // dispatch to prevent compile messages after the static_assert
|
_add_impl(table, ok()); // dispatch to prevent compile messages after the static_assert
|
||||||
}
|
}
|
||||||
@ -240,12 +237,7 @@ namespace sqlpp
|
|||||||
|
|
||||||
// Interpreters
|
// Interpreters
|
||||||
template <typename Context, typename Database, typename... Tables>
|
template <typename Context, typename Database, typename... Tables>
|
||||||
struct serializer_t<Context, using_data_t<Database, Tables...>>
|
Context& serialize(const using_data_t<Database, Tables...>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = serialize_check_of<Context, Tables...>;
|
|
||||||
using T = using_data_t<Database, Tables...>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
if (sizeof...(Tables) == 0 and t._dynamic_tables.empty())
|
if (sizeof...(Tables) == 0 and t._dynamic_tables.empty())
|
||||||
{
|
{
|
||||||
@ -260,7 +252,6 @@ namespace sqlpp
|
|||||||
interpret_list(t._dynamic_tables, ',', context);
|
interpret_list(t._dynamic_tables, ',', context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -57,17 +57,11 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename ValueType>
|
template <typename Context, typename ValueType>
|
||||||
struct serializer_t<Context, verbatim_t<ValueType>>
|
Context& serialize(const verbatim_t<ValueType>& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using T = verbatim_t<ValueType>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
context << t._verbatim;
|
context << t._verbatim;
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename ValueType, typename StringType>
|
template <typename ValueType, typename StringType>
|
||||||
auto verbatim(StringType s) -> verbatim_t<ValueType>
|
auto verbatim(StringType s) -> verbatim_t<ValueType>
|
||||||
|
@ -76,17 +76,11 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
struct serializer_t<Context, verbatim_table_t>
|
Context& serialize(const verbatim_table_t& t, Context& context)
|
||||||
{
|
|
||||||
using _serialize_check = consistent_t;
|
|
||||||
using T = verbatim_table_t;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
{
|
||||||
context << t._representation;
|
context << t._representation;
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
inline verbatim_table_t verbatim_table(std::string name)
|
inline verbatim_table_t verbatim_table(std::string name)
|
||||||
{
|
{
|
||||||
|
@ -93,10 +93,7 @@ namespace sqlpp
|
|||||||
"expression uses tables unknown to this statement in where::add()");
|
"expression uses tables unknown to this statement in where::add()");
|
||||||
static_assert(not contains_aggregate_function_t<Expr>::value,
|
static_assert(not contains_aggregate_function_t<Expr>::value,
|
||||||
"where expression must not contain aggregate functions");
|
"where expression must not contain aggregate functions");
|
||||||
using _serialize_check = sqlpp::serialize_check_t<typename Database::_serializer_context_t, Expr>;
|
using ok = logic::all_t<_is_dynamic::value, is_expression_t<Expr>::value>;
|
||||||
_serialize_check{};
|
|
||||||
|
|
||||||
using ok = logic::all_t<_is_dynamic::value, is_expression_t<Expr>::value, _serialize_check::type::value>;
|
|
||||||
|
|
||||||
_add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert
|
_add_impl(expression, ok()); // dispatch to prevent compile messages after the static_assert
|
||||||
}
|
}
|
||||||
|
@ -191,13 +191,9 @@ namespace sqlpp
|
|||||||
|
|
||||||
// Interpreters
|
// Interpreters
|
||||||
template <typename Context, typename Database, typename... Expressions>
|
template <typename Context, typename Database, typename... Expressions>
|
||||||
struct serializer_t<Context, with_data_t<Database, Expressions...>>
|
Context& serialize(const with_data_t<Database, Expressions...>& t, Context& context)
|
||||||
{
|
{
|
||||||
using _serialize_check = serialize_check_of<Context, Expressions...>;
|
|
||||||
using T = with_data_t<Database, Expressions...>;
|
using T = with_data_t<Database, Expressions...>;
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
|
||||||
// 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)
|
if (T::_is_recursive::value)
|
||||||
@ -208,7 +204,6 @@ namespace sqlpp
|
|||||||
context << ' ';
|
context << ' ';
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename... Expressions>
|
template <typename... Expressions>
|
||||||
auto with(Expressions... cte) -> blank_with_t<void, Expressions...>
|
auto with(Expressions... cte) -> blank_with_t<void, Expressions...>
|
||||||
|
@ -33,27 +33,23 @@
|
|||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
template <typename Expression>
|
template <typename Expression>
|
||||||
struct without_table_check_t : Expression
|
struct without_table_check_t: public Expression
|
||||||
{
|
{
|
||||||
using _required_tables = detail::type_set<>;
|
using _required_tables = detail::type_set<>;
|
||||||
|
|
||||||
without_table_check_t(Expression expression) : Expression(expression)
|
without_table_check_t(Expression expression) : Expression(expression)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Expression& expr() const { return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context, typename Expression>
|
template <typename Context, typename Expression>
|
||||||
struct serializer_t<Context, without_table_check_t<Expression>>
|
Context& serialize(const without_table_check_t<Expression>& t, Context& context)
|
||||||
{
|
{
|
||||||
using _serialize_check = serialize_check_of<Context, Expression>;
|
serialize(t.expr(), context);
|
||||||
using T = without_table_check_t<Expression>;
|
|
||||||
|
|
||||||
static Context& _(const T& t, Context& context)
|
|
||||||
{
|
|
||||||
serialize<Expression>(t, context);
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Expression>
|
template <typename Expression>
|
||||||
auto without_table_check(Expression expr) -> without_table_check_t<Expression>
|
auto without_table_check(Expression expr) -> without_table_check_t<Expression>
|
||||||
|
@ -30,21 +30,21 @@ target_compile_options(sqlpp11_testing INTERFACE -Wall -Wextra -pedantic)
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set(test_names
|
set(test_names
|
||||||
#BooleanExpression
|
BooleanExpression
|
||||||
#CustomQuery
|
CustomQuery
|
||||||
#DateTime
|
DateTime
|
||||||
#Interpret
|
Interpret
|
||||||
#Insert
|
Insert
|
||||||
#Remove
|
Remove
|
||||||
#Update
|
Update
|
||||||
Select
|
Select
|
||||||
#SelectType
|
SelectType
|
||||||
#Function
|
Function
|
||||||
#Prepared
|
Prepared
|
||||||
#Minimalistic
|
Minimalistic
|
||||||
#Result
|
Result
|
||||||
#Union
|
Union
|
||||||
#With
|
With
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package(Boost 1.50)
|
find_package(Boost 1.50)
|
||||||
|
@ -142,11 +142,6 @@ namespace test
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
template <typename Context>
|
|
||||||
Context& serialize(const TabFoo&, Context& context)
|
|
||||||
{
|
|
||||||
return serialize(sqlpp::table_t<TabFoo, TabFoo_::Delta, TabFoo_::Epsilon, TabFoo_::Omega, TabFoo_::Psi, TabFoo_::Book>{}, context);
|
|
||||||
}
|
|
||||||
namespace TabBar_
|
namespace TabBar_
|
||||||
{
|
{
|
||||||
struct Alpha
|
struct Alpha
|
||||||
@ -261,11 +256,6 @@ namespace test
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
template <typename Context>
|
|
||||||
Context& serialize(const TabBar&, Context& context)
|
|
||||||
{
|
|
||||||
return serialize(sqlpp::table_t<TabBar, TabBar_::Alpha, TabBar_::Beta, TabBar_::Gamma, TabBar_::Delta>{}, context);
|
|
||||||
}
|
|
||||||
namespace TabDateTime_
|
namespace TabDateTime_
|
||||||
{
|
{
|
||||||
struct ColDayPoint
|
struct ColDayPoint
|
||||||
@ -358,11 +348,5 @@ namespace test
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Context>
|
|
||||||
Context& serialize(const TabDateTime&, Context& context)
|
|
||||||
{
|
|
||||||
return serialize(sqlpp::table_t<TabDateTime, TabDateTime_::ColDayPoint, TabDateTime_::ColTimePoint, TabDateTime_::ColTimeOfDay>{}, context);
|
|
||||||
}
|
|
||||||
} // namespace test
|
} // namespace test
|
||||||
#endif
|
#endif
|
||||||
|
@ -74,7 +74,6 @@ int Select(int, char*[])
|
|||||||
select(count(t.alpha));
|
select(count(t.alpha));
|
||||||
|
|
||||||
std::cerr << serialize(select(sqlpp::value(false).as(sqlpp::alias::a)), printer).str() << std::endl;
|
std::cerr << serialize(select(sqlpp::value(false).as(sqlpp::alias::a)), printer).str() << std::endl;
|
||||||
/*
|
|
||||||
for (const auto& row : db(select(sqlpp::value(false).as(sqlpp::alias::a))))
|
for (const auto& row : db(select(sqlpp::value(false).as(sqlpp::alias::a))))
|
||||||
{
|
{
|
||||||
std::cout << row.a << std::endl;
|
std::cout << row.a << std::endl;
|
||||||
@ -210,7 +209,6 @@ int Select(int, char*[])
|
|||||||
std::cout << "Error: transaction isolation level does not match default level" << std::endl;
|
std::cout << "Error: transaction isolation level does not match default level" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user