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

Added static assert to give clearer error message for dynamic_xy

This commit is contained in:
rbock 2014-09-29 13:45:29 +02:00
parent a4721ff31e
commit 11950bc0c7
4 changed files with 11 additions and 1 deletions

View File

@ -28,6 +28,7 @@
#define SQLPP_INSERT_H
#include <sqlpp11/statement.h>
#include <sqlpp11/connection.h>
#include <sqlpp11/type_traits.h>
#include <sqlpp11/parameter_list.h>
#include <sqlpp11/prepared_insert.h>
@ -111,6 +112,7 @@ namespace sqlpp
constexpr auto dynamic_insert(const Database&)
-> decltype(blank_insert_t<Database>())
{
static_assert(std::is_base_of<connection, Database>::value, "Invalid database parameter");
return { blank_insert_t<Database>() };
}
@ -118,6 +120,7 @@ namespace sqlpp
constexpr auto dynamic_insert_into(const Database&, Table table)
-> decltype(blank_insert_t<Database>().into(table))
{
static_assert(std::is_base_of<connection, Database>::value, "Invalid database parameter");
return { blank_insert_t<Database>().into(table) };
}
}

View File

@ -28,6 +28,7 @@
#define SQLPP_REMOVE_H
#include <sqlpp11/statement.h>
#include <sqlpp11/connection.h>
#include <sqlpp11/type_traits.h>
#include <sqlpp11/parameter_list.h>
#include <sqlpp11/prepared_remove.h>
@ -115,6 +116,7 @@ namespace sqlpp
auto dynamic_remove(const Database&)
-> decltype(blank_remove_t<Database>())
{
static_assert(std::is_base_of<connection, Database>::value, "Invalid database parameter");
return { blank_remove_t<Database>() };
}
@ -122,6 +124,7 @@ namespace sqlpp
auto dynamic_remove_from(const Database&, Table table)
-> decltype(blank_remove_t<Database>().from(table))
{
static_assert(std::is_base_of<connection, Database>::value, "Invalid database parameter");
return { blank_remove_t<Database>().from(table) };
}
}

View File

@ -30,6 +30,7 @@
#include <sqlpp11/statement.h>
#include <sqlpp11/noop.h>
#include <sqlpp11/connection.h>
#include <sqlpp11/select_flag_list.h>
#include <sqlpp11/select_column_list.h>
#include <sqlpp11/from.h>
@ -94,6 +95,7 @@ namespace sqlpp
template<typename Database>
blank_select_t<Database> dynamic_select(const Database&)
{
static_assert(std::is_base_of<connection, Database>::value, "Invalid database parameter");
return { };
}
@ -101,6 +103,7 @@ namespace sqlpp
auto dynamic_select(const Database&, Columns... columns)
-> decltype(blank_select_t<Database>().columns(columns...))
{
static_assert(std::is_base_of<connection, Database>::value, "Invalid database parameter");
return blank_select_t<Database>().columns(columns...);
}

View File

@ -28,7 +28,7 @@
#define SQLPP_UPDATE_H
#include <sqlpp11/statement.h>
#include <sqlpp11/connection.h>
#include <sqlpp11/type_traits.h>
#include <sqlpp11/parameter_list.h>
#include <sqlpp11/prepared_update.h>
@ -109,6 +109,7 @@ namespace sqlpp
constexpr auto dynamic_update(const Database&, Table table)
-> decltype(blank_update_t<Database>().from(table))
{
static_assert(std::is_base_of<connection, Database>::value, "Invalid database parameter");
return { blank_update_t<Database>().from(table) };
}
}