mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Added more specific static asserts for the consistency checks
This commit is contained in:
parent
7ba973d9af
commit
935baebedb
@ -120,6 +120,7 @@ namespace sqlpp
|
||||
template<typename Policies>
|
||||
struct _methods_t
|
||||
{
|
||||
// FIXME: We might want to check if we have too many tables define in the FROM
|
||||
using _consistency_check = consistent_t;
|
||||
};
|
||||
};
|
||||
|
@ -55,6 +55,17 @@ namespace sqlpp
|
||||
interpretable_list_t<Database> _dynamic_expressions;
|
||||
};
|
||||
|
||||
struct assert_no_unknown_tables_in_group_by_t
|
||||
{
|
||||
using type = std::false_type;
|
||||
|
||||
template<typename T = void>
|
||||
static void _()
|
||||
{
|
||||
static_assert(wrong_t<T>::value, "at least one group-by expression requires a table which is otherwise not known in the statement");
|
||||
}
|
||||
};
|
||||
|
||||
// GROUP BY
|
||||
template<typename Database, typename... Expressions>
|
||||
struct group_by_t
|
||||
@ -128,7 +139,9 @@ namespace sqlpp
|
||||
template<typename Policies>
|
||||
struct _methods_t
|
||||
{
|
||||
using _consistency_check = consistent_t;
|
||||
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<group_by_t>::value,
|
||||
consistent_t,
|
||||
assert_no_unknown_tables_in_group_by_t>::type;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -54,6 +54,17 @@ namespace sqlpp
|
||||
interpretable_list_t<Database> _dynamic_expressions;
|
||||
};
|
||||
|
||||
struct assert_no_unknown_tables_in_having_t
|
||||
{
|
||||
using type = std::false_type;
|
||||
|
||||
template<typename T = void>
|
||||
static void _()
|
||||
{
|
||||
static_assert(wrong_t<T>::value, "at least one having-expression requires a table which is otherwise not known in the statement");
|
||||
}
|
||||
};
|
||||
|
||||
// HAVING
|
||||
template<typename Database, typename... Expressions>
|
||||
struct having_t
|
||||
@ -126,7 +137,9 @@ namespace sqlpp
|
||||
template<typename Policies>
|
||||
struct _methods_t
|
||||
{
|
||||
using _consistency_check = consistent_t;
|
||||
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<having_t>::value,
|
||||
consistent_t,
|
||||
assert_no_unknown_tables_in_having_t>::type;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -236,6 +236,17 @@ namespace sqlpp
|
||||
std::vector<_value_tuple_t> _insert_values;
|
||||
};
|
||||
|
||||
struct assert_no_unknown_tables_in_column_list_t
|
||||
{
|
||||
using type = std::false_type;
|
||||
|
||||
template<typename T = void>
|
||||
static void _()
|
||||
{
|
||||
static_assert(wrong_t<T>::value, "at least one column requires a table which is otherwise not known in the statement");
|
||||
}
|
||||
};
|
||||
|
||||
template<typename... Columns>
|
||||
struct column_list_t
|
||||
{
|
||||
@ -301,7 +312,9 @@ namespace sqlpp
|
||||
template<typename Policies>
|
||||
struct _methods_t
|
||||
{
|
||||
using _consistency_check = consistent_t;
|
||||
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<column_list_t>::value,
|
||||
consistent_t,
|
||||
assert_no_unknown_tables_in_column_list_t>::type;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -55,6 +55,17 @@ namespace sqlpp
|
||||
interpretable_list_t<Database> _dynamic_expressions;
|
||||
};
|
||||
|
||||
struct assert_no_unknown_tables_in_order_by_t
|
||||
{
|
||||
using type = std::false_type;
|
||||
|
||||
template<typename T = void>
|
||||
static void _()
|
||||
{
|
||||
static_assert(wrong_t<T>::value, "at least one order-by expression requires a table which is otherwise not known in the statement");
|
||||
}
|
||||
};
|
||||
|
||||
// ORDER BY
|
||||
template<typename Database, typename... Expressions>
|
||||
struct order_by_t
|
||||
@ -128,7 +139,9 @@ namespace sqlpp
|
||||
template<typename Policies>
|
||||
struct _methods_t
|
||||
{
|
||||
using _consistency_check = consistent_t;
|
||||
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<order_by_t>::value,
|
||||
consistent_t,
|
||||
assert_no_unknown_tables_in_order_by_t>::type;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -52,6 +52,17 @@ namespace sqlpp
|
||||
interpretable_list_t<Database> _dynamic_assignments;
|
||||
};
|
||||
|
||||
struct assert_no_unknown_tables_in_update_assignments_t
|
||||
{
|
||||
using type = std::false_type;
|
||||
|
||||
template<typename T = void>
|
||||
static void _()
|
||||
{
|
||||
static_assert(wrong_t<T>::value, "at least one update assignment requires a table which is otherwise not known in the statement");
|
||||
}
|
||||
};
|
||||
|
||||
// UPDATE ASSIGNMENTS
|
||||
template<typename Database, typename... Assignments>
|
||||
struct update_list_t
|
||||
@ -124,7 +135,9 @@ namespace sqlpp
|
||||
template<typename Policies>
|
||||
struct _methods_t
|
||||
{
|
||||
using _consistency_check = consistent_t;
|
||||
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<update_list_t>::value,
|
||||
consistent_t,
|
||||
assert_no_unknown_tables_in_update_assignments_t>::type;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -121,6 +121,7 @@ namespace sqlpp
|
||||
template<typename Policies>
|
||||
struct _methods_t
|
||||
{
|
||||
// FIXME: Maybe check for unused tables, similar to from
|
||||
using _consistency_check = consistent_t;
|
||||
};
|
||||
};
|
||||
|
@ -55,6 +55,17 @@ namespace sqlpp
|
||||
interpretable_list_t<Database> _dynamic_expressions;
|
||||
};
|
||||
|
||||
struct assert_no_unknown_tables_in_where_t
|
||||
{
|
||||
using type = std::false_type;
|
||||
|
||||
template<typename T = void>
|
||||
static void _()
|
||||
{
|
||||
static_assert(wrong_t<T>::value, "at least one expression in where() requires a table which is otherwise not known in the statement");
|
||||
}
|
||||
};
|
||||
|
||||
// WHERE(EXPR)
|
||||
template<typename Database, typename... Expressions>
|
||||
struct where_t
|
||||
@ -128,8 +139,9 @@ namespace sqlpp
|
||||
template<typename Policies>
|
||||
struct _methods_t
|
||||
{
|
||||
#warning: here and elsewhere: add check for missing tables (see select columns, for instance)
|
||||
using _consistency_check = consistent_t;
|
||||
using _consistency_check = typename std::conditional<Policies::template _no_unknown_tables<where_t>::value,
|
||||
consistent_t,
|
||||
assert_no_unknown_tables_in_where_t>::type;
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user