From 11950bc0c7a2d1987f580a50f4ccdbeedae18928 Mon Sep 17 00:00:00 2001 From: rbock Date: Mon, 29 Sep 2014 13:45:29 +0200 Subject: [PATCH] Added static assert to give clearer error message for dynamic_xy --- include/sqlpp11/insert.h | 3 +++ include/sqlpp11/remove.h | 3 +++ include/sqlpp11/select.h | 3 +++ include/sqlpp11/update.h | 3 ++- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/sqlpp11/insert.h b/include/sqlpp11/insert.h index 408225da..d6e1bc3a 100644 --- a/include/sqlpp11/insert.h +++ b/include/sqlpp11/insert.h @@ -28,6 +28,7 @@ #define SQLPP_INSERT_H #include +#include #include #include #include @@ -111,6 +112,7 @@ namespace sqlpp constexpr auto dynamic_insert(const Database&) -> decltype(blank_insert_t()) { + static_assert(std::is_base_of::value, "Invalid database parameter"); return { blank_insert_t() }; } @@ -118,6 +120,7 @@ namespace sqlpp constexpr auto dynamic_insert_into(const Database&, Table table) -> decltype(blank_insert_t().into(table)) { + static_assert(std::is_base_of::value, "Invalid database parameter"); return { blank_insert_t().into(table) }; } } diff --git a/include/sqlpp11/remove.h b/include/sqlpp11/remove.h index 0225af13..c607b847 100644 --- a/include/sqlpp11/remove.h +++ b/include/sqlpp11/remove.h @@ -28,6 +28,7 @@ #define SQLPP_REMOVE_H #include +#include #include #include #include @@ -115,6 +116,7 @@ namespace sqlpp auto dynamic_remove(const Database&) -> decltype(blank_remove_t()) { + static_assert(std::is_base_of::value, "Invalid database parameter"); return { blank_remove_t() }; } @@ -122,6 +124,7 @@ namespace sqlpp auto dynamic_remove_from(const Database&, Table table) -> decltype(blank_remove_t().from(table)) { + static_assert(std::is_base_of::value, "Invalid database parameter"); return { blank_remove_t().from(table) }; } } diff --git a/include/sqlpp11/select.h b/include/sqlpp11/select.h index c7e92c4a..3a2556a5 100644 --- a/include/sqlpp11/select.h +++ b/include/sqlpp11/select.h @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -94,6 +95,7 @@ namespace sqlpp template blank_select_t dynamic_select(const Database&) { + static_assert(std::is_base_of::value, "Invalid database parameter"); return { }; } @@ -101,6 +103,7 @@ namespace sqlpp auto dynamic_select(const Database&, Columns... columns) -> decltype(blank_select_t().columns(columns...)) { + static_assert(std::is_base_of::value, "Invalid database parameter"); return blank_select_t().columns(columns...); } diff --git a/include/sqlpp11/update.h b/include/sqlpp11/update.h index 09eb71a3..492f0791 100644 --- a/include/sqlpp11/update.h +++ b/include/sqlpp11/update.h @@ -28,7 +28,7 @@ #define SQLPP_UPDATE_H #include - +#include #include #include #include @@ -109,6 +109,7 @@ namespace sqlpp constexpr auto dynamic_update(const Database&, Table table) -> decltype(blank_update_t().from(table)) { + static_assert(std::is_base_of::value, "Invalid database parameter"); return { blank_update_t().from(table) }; } }