mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-04 20:20:59 -06:00
Improved error messages for incorrect parameters.
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
#ifndef SQLPP_ALIAS_PROVIDER_H
|
||||
#define SQLPP_ALIAS_PROVIDER_H
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#define SQLPP_ALIAS_PROVIDER(name) \
|
||||
struct name##_t\
|
||||
{\
|
||||
@@ -46,6 +48,18 @@
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template<typename T, typename Enable = void>
|
||||
struct is_alias_provider_t
|
||||
{
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct is_alias_provider_t<T, typename std::enable_if<std::is_class<typename T::_name_t::template _member_t<int>>::value, void>::type>
|
||||
{
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
namespace alias
|
||||
{
|
||||
SQLPP_ALIAS_PROVIDER(a);
|
||||
|
||||
@@ -35,7 +35,6 @@ namespace sqlpp
|
||||
template<typename ValueType, typename NameType>
|
||||
struct parameter_t: public ValueType::template expression_operators<parameter_t<ValueType, NameType>>
|
||||
{
|
||||
#warning need to check that Value Type is an SQL value type!
|
||||
struct _value_type: public ValueType
|
||||
{
|
||||
using _is_expression = std::true_type;
|
||||
@@ -74,6 +73,7 @@ namespace sqlpp
|
||||
auto parameter(const NamedExpr&)
|
||||
-> parameter_t<typename NamedExpr::_value_type, NamedExpr>
|
||||
{
|
||||
static_assert(is_named_expression_t<NamedExpr>::value, "not a named expression");
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -81,6 +81,8 @@ namespace sqlpp
|
||||
auto parameter(const ValueType&, const AliasProvider&)
|
||||
-> parameter_t<ValueType, AliasProvider>
|
||||
{
|
||||
static_assert(is_expression_t<ValueType>::value, "first argument is not an expression");
|
||||
static_assert(is_alias_provider_t<AliasProvider>::value, "second argument is not an alias provider");
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user