From 1c95406ceddd8271eec870cfb4bea15217d0a3f3 Mon Sep 17 00:00:00 2001 From: rbock Date: Wed, 26 Mar 2014 21:01:16 +0100 Subject: [PATCH] Improved error messages for incorrect parameters. --- include/sqlpp11/alias_provider.h | 14 ++++++++++++++ include/sqlpp11/parameter.h | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/sqlpp11/alias_provider.h b/include/sqlpp11/alias_provider.h index d63ce097..a0cd3789 100644 --- a/include/sqlpp11/alias_provider.h +++ b/include/sqlpp11/alias_provider.h @@ -27,6 +27,8 @@ #ifndef SQLPP_ALIAS_PROVIDER_H #define SQLPP_ALIAS_PROVIDER_H +#include + #define SQLPP_ALIAS_PROVIDER(name) \ struct name##_t\ {\ @@ -46,6 +48,18 @@ namespace sqlpp { + template + struct is_alias_provider_t + { + static constexpr bool value = false; + }; + + template + struct is_alias_provider_t>::value, void>::type> + { + static constexpr bool value = true; + }; + namespace alias { SQLPP_ALIAS_PROVIDER(a); diff --git a/include/sqlpp11/parameter.h b/include/sqlpp11/parameter.h index 8029ad02..c4f183fc 100644 --- a/include/sqlpp11/parameter.h +++ b/include/sqlpp11/parameter.h @@ -35,7 +35,6 @@ namespace sqlpp template struct parameter_t: public ValueType::template expression_operators> { -#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 { + static_assert(is_named_expression_t::value, "not a named expression"); return {}; } @@ -81,6 +81,8 @@ namespace sqlpp auto parameter(const ValueType&, const AliasProvider&) -> parameter_t { + static_assert(is_expression_t::value, "first argument is not an expression"); + static_assert(is_alias_provider_t::value, "second argument is not an alias provider"); return {}; }