0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 04:47:18 +08:00

Removed where(true).

This commit is contained in:
rbock 2016-02-26 22:28:11 +01:00
parent 15247504f2
commit 8079015d2c

View File

@ -154,70 +154,6 @@ namespace sqlpp
}; };
}; };
#ifdef SQLPP_ALLOW_NAKED_BOOL_EXPRESSION
template <>
struct where_data_t<void, bool>
{
bool _condition;
};
// WHERE(BOOL)
template <>
struct where_t<void, bool>
{
using _traits = make_traits<no_value_t, tag::is_where>;
using _nodes = detail::type_vector<>;
// Data
using _data_t = where_data_t<void, bool>;
// Member implementation with data and methods
template <typename Policies>
struct _impl_t
{
// workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2173269
_impl_t() = default;
_impl_t(const _data_t& data) : _data(data)
{
}
_data_t _data;
};
// Base template to be inherited by the statement
template <typename Policies>
struct _base_t
{
using _data_t = where_data_t<void, bool>;
// workaround for msvc bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2173269
template <typename... Args>
_base_t(Args&&... args)
: where{std::forward<Args>(args)...}
{
}
_impl_t<Policies> where;
_impl_t<Policies>& operator()()
{
return where;
}
const _impl_t<Policies>& operator()() const
{
return where;
}
template <typename T>
static auto _get_member(T t) -> decltype(t.where)
{
return t.where;
}
using _consistency_check = consistent_t;
};
};
#endif
template <> template <>
struct where_data_t<void, unconditional_t> struct where_data_t<void, unconditional_t>
{ {
@ -392,23 +328,14 @@ namespace sqlpp
assert_where_t, assert_where_t,
consistent_t>::type; consistent_t>::type;
#ifdef SQLPP_ALLOW_NAKED_BOOL_EXPRESSION
template <typename T = void> template <typename T = void>
auto where(bool b) const -> _new_statement_t<std::true_type, where_t<void, bool>> auto where(bool) const -> bad_statement
{ {
return {static_cast<const derived_statement_t<Policies>&>(*this), where_data_t<void, bool>{b}}; static_assert(wrong_t<T>::value,
".where(bool) is not allowed any more. Please use unconditionally() to replace "
".where(true). Use sqlpp::value(bool) if you really want to use a bool here");
return {};
} }
#else
template <typename T = void>
auto where(bool b) const -> bad_statement
{
static_assert(
wrong_t<T>::value,
"where(bool) is deprecated, please use unconditionally() or #define SQLPP_ALLOW_NAKED_BOOL_EXPRESSION "
"for a grace period");
return {static_cast<const derived_statement_t<Policies>&>(*this), where_data_t<void, bool>{b}};
}
#endif
auto unconditionally() const -> _new_statement_t<std::true_type, where_t<void, unconditional_t>> auto unconditionally() const -> _new_statement_t<std::true_type, where_t<void, unconditional_t>>
{ {
@ -469,22 +396,6 @@ namespace sqlpp
} }
}; };
#ifdef SQLPP_ALLOW_NAKED_BOOL_EXPRESSION
template <typename Context>
struct serializer_t<Context, where_data_t<void, bool>>
{
using _serialize_check = consistent_t;
using T = where_data_t<void, bool>;
static Context& _(const T& t, Context& context)
{
if (not t._condition)
context << " WHERE NULL";
return context;
}
};
#endif
template <typename Context> template <typename Context>
struct serializer_t<Context, where_data_t<void, unconditional_t>> struct serializer_t<Context, where_data_t<void, unconditional_t>>
{ {