mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-06 05:00:37 -06:00
Reformatted using clang-format
Please use clang-format before submitting code, e.g via the pre-commit supplied in the repo (thanks AndiDog)
This commit is contained in:
@@ -28,17 +28,16 @@
|
||||
#include "MockDb.h"
|
||||
#include <sqlpp11/sqlpp11.h>
|
||||
|
||||
|
||||
int BooleanExpression(int, char**)
|
||||
{
|
||||
MockDb db = {};
|
||||
test::TabBar t;
|
||||
MockDb db = {};
|
||||
test::TabBar t;
|
||||
|
||||
auto x = boolean_expression(db, t.alpha == 7);
|
||||
x = sqlpp::boolean_expression<MockDb>(t.beta.like("%cheesecake"));
|
||||
x = x and boolean_expression(db, t.gamma);
|
||||
auto x = boolean_expression(db, t.alpha == 7);
|
||||
x = sqlpp::boolean_expression<MockDb>(t.beta.like("%cheesecake"));
|
||||
x = x and boolean_expression(db, t.gamma);
|
||||
|
||||
db(select(t.alpha).from(t).where(x));
|
||||
db(select(t.alpha).from(t).where(x));
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -31,37 +31,39 @@
|
||||
|
||||
int CustomQuery(int, char**)
|
||||
{
|
||||
MockDb db = {};
|
||||
MockDb::_serializer_context_t printer;
|
||||
MockDb db = {};
|
||||
MockDb::_serializer_context_t printer;
|
||||
|
||||
test::TabFoo f;
|
||||
test::TabBar t;
|
||||
test::TabFoo f;
|
||||
test::TabBar t;
|
||||
|
||||
// A void custom query
|
||||
printer.reset();
|
||||
auto x = custom_query(sqlpp::verbatim("PRAGMA writeable_schema = "), true);
|
||||
std::cerr << serialize(x, printer).str() << std::endl;
|
||||
db(x);
|
||||
// A void custom query
|
||||
printer.reset();
|
||||
auto x = custom_query(sqlpp::verbatim("PRAGMA writeable_schema = "), true);
|
||||
std::cerr << serialize(x, printer).str() << std::endl;
|
||||
db(x);
|
||||
|
||||
// Syntactically, it is possible to use this void query as a prepared statement, too, not sure, whether this makes sense very often...
|
||||
db(db.prepare(x));
|
||||
// Syntactically, it is possible to use this void query as a prepared statement, too, not sure, whether this makes
|
||||
// sense very often...
|
||||
db(db.prepare(x));
|
||||
|
||||
// A prepared custom select
|
||||
// The return type of the custom query is determined from the first argument which does have a return type, in this case the select
|
||||
auto p = db.prepare(custom_query(select(all_of(t)).from(t), where(t.alpha > sqlpp::parameter(t.alpha))));
|
||||
p.params.alpha = 8;
|
||||
for (const auto& row : db(p))
|
||||
{
|
||||
std::cerr << row.alpha << std::endl;
|
||||
}
|
||||
// A prepared custom select
|
||||
// The return type of the custom query is determined from the first argument which does have a return type, in this
|
||||
// case the select
|
||||
auto p = db.prepare(custom_query(select(all_of(t)).from(t), where(t.alpha > sqlpp::parameter(t.alpha))));
|
||||
p.params.alpha = 8;
|
||||
for (const auto& row : db(p))
|
||||
{
|
||||
std::cerr << row.alpha << std::endl;
|
||||
}
|
||||
|
||||
// A custom (select ... into) with adjusted return type
|
||||
// The first argument with a return type is the select, but the custom query is really an insert. Thus, we tell it so.
|
||||
printer.reset();
|
||||
auto c = custom_query(select(all_of(t)).from(t), into(f)).with_result_type_of(insert_into(f));
|
||||
std::cerr << serialize(c, printer).str() << std::endl;
|
||||
auto i = db(c);
|
||||
static_assert(std::is_integral<decltype(i)>::value, "insert yields an integral value");
|
||||
// A custom (select ... into) with adjusted return type
|
||||
// The first argument with a return type is the select, but the custom query is really an insert. Thus, we tell it so.
|
||||
printer.reset();
|
||||
auto c = custom_query(select(all_of(t)).from(t), into(f)).with_result_type_of(insert_into(f));
|
||||
std::cerr << serialize(c, printer).str() << std::endl;
|
||||
auto i = db(c);
|
||||
static_assert(std::is_integral<decltype(i)>::value, "insert yields an integral value");
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -37,413 +37,423 @@ SQLPP_ALIAS_PROVIDER(kaesekuchen)
|
||||
|
||||
int Function(int, char**)
|
||||
{
|
||||
MockDb db = {};
|
||||
test::TabFoo f;
|
||||
test::TabBar t;
|
||||
MockDb db = {};
|
||||
test::TabFoo f;
|
||||
test::TabBar t;
|
||||
|
||||
//f.omega + 4 *= "";
|
||||
// f.omega + 4 *= "";
|
||||
|
||||
// MEMBER FUNCTIONS
|
||||
// ----------------
|
||||
// MEMBER FUNCTIONS
|
||||
// ----------------
|
||||
|
||||
// Test in
|
||||
{
|
||||
using TI = decltype(t.alpha.in(1, 2, 3));
|
||||
using TF = decltype(f.omega.in(1.0, 2.0, 3.0));
|
||||
using TT = decltype(t.beta.in("a", "b", "c"));
|
||||
static_assert(sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
// Test in
|
||||
{
|
||||
using TI = decltype(t.alpha.in(1, 2, 3));
|
||||
using TF = decltype(f.omega.in(1.0, 2.0, 3.0));
|
||||
using TT = decltype(t.beta.in("a", "b", "c"));
|
||||
static_assert(sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test in with value list
|
||||
{
|
||||
using TI = decltype(t.alpha.in(sqlpp::value_list(std::vector<int>({1, 2, 3}))));
|
||||
using TF = decltype(f.omega.in(sqlpp::value_list(std::vector<float>({1.0, 2.0, 3.0}))));
|
||||
using TT = decltype(t.beta.in(sqlpp::value_list(std::vector<std::string>({"a", "b", "c"}))));
|
||||
static_assert(sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
// Test in with value list
|
||||
{
|
||||
using TI = decltype(t.alpha.in(sqlpp::value_list(std::vector<int>({1, 2, 3}))));
|
||||
using TF = decltype(f.omega.in(sqlpp::value_list(std::vector<float>({1.0, 2.0, 3.0}))));
|
||||
using TT = decltype(t.beta.in(sqlpp::value_list(std::vector<std::string>({"a", "b", "c"}))));
|
||||
static_assert(sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test not_in
|
||||
{
|
||||
using TI = decltype(t.alpha.not_in(1, 2, 3));
|
||||
using TF = decltype(f.omega.not_in(1.0, 2.0, 3.0));
|
||||
using TT = decltype(t.beta.not_in("a", "b", "c"));
|
||||
static_assert(sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
// Test not_in
|
||||
{
|
||||
using TI = decltype(t.alpha.not_in(1, 2, 3));
|
||||
using TF = decltype(f.omega.not_in(1.0, 2.0, 3.0));
|
||||
using TT = decltype(t.beta.not_in("a", "b", "c"));
|
||||
static_assert(sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test not in with value list
|
||||
{
|
||||
using TI = decltype(t.alpha.not_in(sqlpp::value_list(std::vector<int>({1, 2, 3}))));
|
||||
using TF = decltype(f.omega.not_in(sqlpp::value_list(std::vector<float>({1.0, 2.0, 3.0}))));
|
||||
using TT = decltype(t.beta.not_in(sqlpp::value_list(std::vector<std::string>({"a", "b", "c"}))));
|
||||
static_assert(sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
// Test not in with value list
|
||||
{
|
||||
using TI = decltype(t.alpha.not_in(sqlpp::value_list(std::vector<int>({1, 2, 3}))));
|
||||
using TF = decltype(f.omega.not_in(sqlpp::value_list(std::vector<float>({1.0, 2.0, 3.0}))));
|
||||
using TT = decltype(t.beta.not_in(sqlpp::value_list(std::vector<std::string>({"a", "b", "c"}))));
|
||||
static_assert(sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test like
|
||||
{
|
||||
using TT = decltype(t.beta.like("%c%"));
|
||||
static_assert(sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
// Test like
|
||||
{
|
||||
using TT = decltype(t.beta.like("%c%"));
|
||||
static_assert(sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test is_null
|
||||
{
|
||||
using TI = decltype(t.alpha.is_null());
|
||||
using TF = decltype(f.omega.is_null());
|
||||
using TT = decltype(t.beta.is_null());
|
||||
using TTI = decltype(is_null(t.alpha));
|
||||
using TTF = decltype(is_null(f.omega));
|
||||
using TTT = decltype(is_null(t.beta));
|
||||
static_assert(std::is_same<TI, TTI>::value, "type requirement");
|
||||
static_assert(std::is_same<TF, TTF>::value, "type requirement");
|
||||
static_assert(std::is_same<TT, TTT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
// Test is_null
|
||||
{
|
||||
using TI = decltype(t.alpha.is_null());
|
||||
using TF = decltype(f.omega.is_null());
|
||||
using TT = decltype(t.beta.is_null());
|
||||
using TTI = decltype(is_null(t.alpha));
|
||||
using TTF = decltype(is_null(f.omega));
|
||||
using TTT = decltype(is_null(t.beta));
|
||||
static_assert(std::is_same<TI, TTI>::value, "type requirement");
|
||||
static_assert(std::is_same<TF, TTF>::value, "type requirement");
|
||||
static_assert(std::is_same<TT, TTT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test is_not_null
|
||||
{
|
||||
using TI = decltype(t.alpha.is_not_null());
|
||||
using TF = decltype(f.omega.is_not_null());
|
||||
using TT = decltype(t.beta.is_not_null());
|
||||
using TTI = decltype(is_not_null(t.alpha));
|
||||
using TTF = decltype(is_not_null(f.omega));
|
||||
using TTT = decltype(is_not_null(t.beta));
|
||||
static_assert(std::is_same<TI, TTI>::value, "type requirement");
|
||||
static_assert(std::is_same<TF, TTF>::value, "type requirement");
|
||||
static_assert(std::is_same<TT, TTT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
// Test is_not_null
|
||||
{
|
||||
using TI = decltype(t.alpha.is_not_null());
|
||||
using TF = decltype(f.omega.is_not_null());
|
||||
using TT = decltype(t.beta.is_not_null());
|
||||
using TTI = decltype(is_not_null(t.alpha));
|
||||
using TTF = decltype(is_not_null(f.omega));
|
||||
using TTT = decltype(is_not_null(t.beta));
|
||||
static_assert(std::is_same<TI, TTI>::value, "type requirement");
|
||||
static_assert(std::is_same<TF, TTF>::value, "type requirement");
|
||||
static_assert(std::is_same<TT, TTT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
|
||||
// SUB_SELECT_FUNCTIONS
|
||||
// --------------------
|
||||
// SUB_SELECT_FUNCTIONS
|
||||
// --------------------
|
||||
|
||||
// Test exists
|
||||
{
|
||||
using TI = decltype(exists(select(t.alpha).from(t)));
|
||||
using TT = decltype(exists(select(t.beta).from(t)));
|
||||
static_assert(sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
// Test exists
|
||||
{
|
||||
using TI = decltype(exists(select(t.alpha).from(t)));
|
||||
using TT = decltype(exists(select(t.beta).from(t)));
|
||||
static_assert(sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
|
||||
if (nullptr and db(select(exists(select(t.alpha).from(t).where(true)))).front().exists) { /* do something */ }
|
||||
}
|
||||
if (nullptr and db(select(exists(select(t.alpha).from(t).where(true)))).front().exists)
|
||||
{ /* do something */
|
||||
}
|
||||
}
|
||||
|
||||
// Test any
|
||||
{
|
||||
using S = decltype(select(t.alpha).from(t));
|
||||
static_assert(sqlpp::is_numeric_t<S>::value, "type requirement");
|
||||
|
||||
// Test any
|
||||
{
|
||||
using S = decltype(select(t.alpha).from(t));
|
||||
static_assert(sqlpp::is_numeric_t<S>::value, "type requirement");
|
||||
using TI = decltype(any(select(t.alpha).from(t)));
|
||||
using TT = decltype(any(select(t.beta).from(t)));
|
||||
using TF = decltype(any(select(f.omega).from(f)));
|
||||
static_assert(not sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_multi_expression_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_multi_expression_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TF>::value, "tFpe requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_multi_expression_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
|
||||
using TI = decltype(any(select(t.alpha).from(t)));
|
||||
using TT = decltype(any(select(t.beta).from(t)));
|
||||
using TF = decltype(any(select(f.omega).from(f)));
|
||||
static_assert(not sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_multi_expression_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_multi_expression_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TF>::value, "tFpe requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_multi_expression_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
// Test some
|
||||
{
|
||||
using TI = decltype(some(select(t.alpha).from(t)));
|
||||
using TT = decltype(some(select(t.beta).from(t)));
|
||||
using TF = decltype(some(select(f.omega).from(f)));
|
||||
static_assert(not sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_multi_expression_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_multi_expression_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_multi_expression_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test some
|
||||
{
|
||||
using TI = decltype(some(select(t.alpha).from(t)));
|
||||
using TT = decltype(some(select(t.beta).from(t)));
|
||||
using TF = decltype(some(select(f.omega).from(f)));
|
||||
static_assert(not sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_multi_expression_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_multi_expression_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_multi_expression_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
|
||||
// NUMERIC FUNCTIONS
|
||||
// NUMERIC FUNCTIONS
|
||||
// -----------------
|
||||
|
||||
// Test avg
|
||||
{
|
||||
using TI = decltype(avg(t.alpha));
|
||||
using TF = decltype(avg(f.omega));
|
||||
static_assert(sqlpp::has_auto_alias_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::has_auto_alias_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
}
|
||||
// Test avg
|
||||
{
|
||||
using TI = decltype(avg(t.alpha));
|
||||
using TF = decltype(avg(f.omega));
|
||||
static_assert(sqlpp::has_auto_alias_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::has_auto_alias_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test count
|
||||
{
|
||||
using TI = decltype(count(t.alpha));
|
||||
using TT = decltype(count(t.beta));
|
||||
using TF = decltype(count(f.omega));
|
||||
static_assert(sqlpp::has_auto_alias_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::has_auto_alias_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::has_auto_alias_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<TT>::value, "type requirement");
|
||||
// Test count
|
||||
{
|
||||
using TI = decltype(count(t.alpha));
|
||||
using TT = decltype(count(t.beta));
|
||||
using TF = decltype(count(f.omega));
|
||||
static_assert(sqlpp::has_auto_alias_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::has_auto_alias_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::has_auto_alias_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<TT>::value, "type requirement");
|
||||
|
||||
if (nullptr and db(select(count(t.alpha)).from(t).where(true)).front().count) { /* do something */ }
|
||||
}
|
||||
if (nullptr and db(select(count(t.alpha)).from(t).where(true)).front().count)
|
||||
{ /* do something */
|
||||
}
|
||||
}
|
||||
|
||||
// Test max
|
||||
{
|
||||
using TI = decltype(max(t.alpha));
|
||||
using TF = decltype(max(f.omega));
|
||||
using TT = decltype(max(t.beta));
|
||||
static_assert(sqlpp::has_auto_alias_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::has_auto_alias_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::has_auto_alias_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
// Test max
|
||||
{
|
||||
using TI = decltype(max(t.alpha));
|
||||
using TF = decltype(max(f.omega));
|
||||
using TT = decltype(max(t.beta));
|
||||
static_assert(sqlpp::has_auto_alias_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::has_auto_alias_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::has_auto_alias_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test min
|
||||
{
|
||||
using TI = decltype(min(t.alpha));
|
||||
using TF = decltype(min(f.omega));
|
||||
using TT = decltype(min(t.beta));
|
||||
static_assert(sqlpp::has_auto_alias_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
// Test min
|
||||
{
|
||||
using TI = decltype(min(t.alpha));
|
||||
using TF = decltype(min(f.omega));
|
||||
using TT = decltype(min(t.beta));
|
||||
static_assert(sqlpp::has_auto_alias_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_numeric_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test sum
|
||||
{
|
||||
using TI = decltype(sum(t.alpha));
|
||||
using TF = decltype(sum(f.omega));
|
||||
static_assert(sqlpp::has_auto_alias_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
}
|
||||
// Test sum
|
||||
{
|
||||
using TI = decltype(sum(t.alpha));
|
||||
using TF = decltype(sum(f.omega));
|
||||
static_assert(sqlpp::has_auto_alias_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<TF>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
}
|
||||
|
||||
// MISC FUNCTIONS
|
||||
// MISC FUNCTIONS
|
||||
// --------------
|
||||
|
||||
// test value
|
||||
{
|
||||
using TB = decltype(sqlpp::value(true));
|
||||
using TI = decltype(sqlpp::value(7));
|
||||
using TF = decltype(sqlpp::value(1.5));
|
||||
using TT = decltype(sqlpp::value("cheesecake"));
|
||||
static_assert(not sqlpp::is_selectable_t<TB>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TB>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TB>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
// test value
|
||||
{
|
||||
using TB = decltype(sqlpp::value(true));
|
||||
using TI = decltype(sqlpp::value(7));
|
||||
using TF = decltype(sqlpp::value(1.5));
|
||||
using TT = decltype(sqlpp::value("cheesecake"));
|
||||
static_assert(not sqlpp::is_selectable_t<TB>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TB>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TB>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
|
||||
// test flatten
|
||||
{
|
||||
using TB = decltype(flatten(t.gamma, db));
|
||||
using TI = decltype(flatten(t.alpha, db));
|
||||
using TF = decltype(flatten(f.omega, db));
|
||||
using TT = decltype(flatten(t.beta, db));
|
||||
static_assert(not sqlpp::is_selectable_t<TB>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TB>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TB>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
// test flatten
|
||||
{
|
||||
using TB = decltype(flatten(t.gamma, db));
|
||||
using TI = decltype(flatten(t.alpha, db));
|
||||
using TF = decltype(flatten(f.omega, db));
|
||||
using TT = decltype(flatten(t.beta, db));
|
||||
static_assert(not sqlpp::is_selectable_t<TB>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TB>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TB>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
|
||||
// test value_or_null
|
||||
{
|
||||
using TB = decltype(sqlpp::value_or_null(true));
|
||||
using TI = decltype(sqlpp::value_or_null(7));
|
||||
using TF = decltype(sqlpp::value_or_null(5.6));
|
||||
using TT = decltype(sqlpp::value_or_null("hallo"));
|
||||
using TBN = decltype(sqlpp::value_or_null<sqlpp::boolean>(sqlpp::null));
|
||||
using TIN = decltype(sqlpp::value_or_null<sqlpp::integral>(sqlpp::null));
|
||||
using TFN = decltype(sqlpp::value_or_null<sqlpp::floating_point>(sqlpp::null));
|
||||
using TTN = decltype(sqlpp::value_or_null<sqlpp::text>(sqlpp::null));
|
||||
static_assert(std::is_same<TB, TBN>::value, "type_requirement");
|
||||
static_assert(std::is_same<TI, TIN>::value, "type_requirement");
|
||||
static_assert(std::is_same<TF, TFN>::value, "type_requirement");
|
||||
static_assert(std::is_same<TT, TTN>::value, "type_requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TB>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TB>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TB>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
// test value_or_null
|
||||
{
|
||||
using TB = decltype(sqlpp::value_or_null(true));
|
||||
using TI = decltype(sqlpp::value_or_null(7));
|
||||
using TF = decltype(sqlpp::value_or_null(5.6));
|
||||
using TT = decltype(sqlpp::value_or_null("hallo"));
|
||||
using TBN = decltype(sqlpp::value_or_null<sqlpp::boolean>(sqlpp::null));
|
||||
using TIN = decltype(sqlpp::value_or_null<sqlpp::integral>(sqlpp::null));
|
||||
using TFN = decltype(sqlpp::value_or_null<sqlpp::floating_point>(sqlpp::null));
|
||||
using TTN = decltype(sqlpp::value_or_null<sqlpp::text>(sqlpp::null));
|
||||
static_assert(std::is_same<TB, TBN>::value, "type_requirement");
|
||||
static_assert(std::is_same<TI, TIN>::value, "type_requirement");
|
||||
static_assert(std::is_same<TF, TFN>::value, "type_requirement");
|
||||
static_assert(std::is_same<TT, TTN>::value, "type_requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TB>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TB>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TB>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
|
||||
// test verbatim
|
||||
{
|
||||
using TB = decltype(sqlpp::verbatim<sqlpp::boolean>("1"));
|
||||
using TI = decltype(sqlpp::verbatim<sqlpp::bigint>("42"));
|
||||
using TF = decltype(sqlpp::verbatim<sqlpp::floating_point>("1.5"));
|
||||
using TT = decltype(sqlpp::verbatim<sqlpp::text>("cheesecake"));
|
||||
static_assert(not sqlpp::is_selectable_t<TB>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TB>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TB>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
// test verbatim
|
||||
{
|
||||
using TB = decltype(sqlpp::verbatim<sqlpp::boolean>("1"));
|
||||
using TI = decltype(sqlpp::verbatim<sqlpp::bigint>("42"));
|
||||
using TF = decltype(sqlpp::verbatim<sqlpp::floating_point>("1.5"));
|
||||
using TT = decltype(sqlpp::verbatim<sqlpp::text>("cheesecake"));
|
||||
static_assert(not sqlpp::is_selectable_t<TB>::value, "type requirement");
|
||||
static_assert(sqlpp::is_boolean_t<TB>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TB>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<TI>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TI>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<TF>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
|
||||
// test verbatim_table
|
||||
{
|
||||
using T = decltype(sqlpp::verbatim_table("cheesecake"));
|
||||
static_assert(not sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_table_t<T>::value, "type requirement");
|
||||
}
|
||||
// test verbatim_table
|
||||
{
|
||||
using T = decltype(sqlpp::verbatim_table("cheesecake"));
|
||||
static_assert(not sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_table_t<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
// test verbatim_table alias
|
||||
{
|
||||
using T = decltype(sqlpp::verbatim_table("cheesecake").as(kaesekuchen));
|
||||
static_assert(not sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
}
|
||||
// test verbatim_table alias
|
||||
{
|
||||
using T = decltype(sqlpp::verbatim_table("cheesecake").as(kaesekuchen));
|
||||
static_assert(not sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
// test tvin
|
||||
{
|
||||
static_assert(std::is_same<decltype(sqlpp::tvin(1)), sqlpp::tvin_arg_t<sqlpp::integral_operand>>::value, "integral values are accepted and wrapped") ;
|
||||
static_assert(std::is_same<decltype(sqlpp::tvin(false)), sqlpp::tvin_arg_t<sqlpp::boolean_operand>>::value, "bool values are accepted and wrapped") ;
|
||||
static_assert(std::is_same<decltype(sqlpp::tvin(0.17)), sqlpp::tvin_arg_t<sqlpp::floating_point_operand>>::value, "float values are accepted and wrapped") ;
|
||||
static_assert(std::is_same<decltype(sqlpp::tvin("test")), sqlpp::tvin_arg_t<sqlpp::text_operand>>::value, "text values are accepted and wrapped") ;
|
||||
// test tvin
|
||||
{
|
||||
static_assert(std::is_same<decltype(sqlpp::tvin(1)), sqlpp::tvin_arg_t<sqlpp::integral_operand>>::value,
|
||||
"integral values are accepted and wrapped");
|
||||
static_assert(std::is_same<decltype(sqlpp::tvin(false)), sqlpp::tvin_arg_t<sqlpp::boolean_operand>>::value,
|
||||
"bool values are accepted and wrapped");
|
||||
static_assert(std::is_same<decltype(sqlpp::tvin(0.17)), sqlpp::tvin_arg_t<sqlpp::floating_point_operand>>::value,
|
||||
"float values are accepted and wrapped");
|
||||
static_assert(std::is_same<decltype(sqlpp::tvin("test")), sqlpp::tvin_arg_t<sqlpp::text_operand>>::value,
|
||||
"text values are accepted and wrapped");
|
||||
|
||||
for (const auto& row : db(select(all_of(t)).from(t).where(true)))
|
||||
{
|
||||
static_assert(std::is_same<decltype(sqlpp::tvin(row.alpha)), sqlpp::tvin_arg_t<decltype(row.alpha)>>::value, "result fields are accepted and not wrapped") ;
|
||||
static_assert(std::is_same<decltype(sqlpp::tvin(row.beta)), sqlpp::tvin_arg_t<decltype(row.beta)>>::value, "result fields are accepted and not wrapped") ;
|
||||
static_assert(std::is_same<decltype(sqlpp::tvin(row.gamma)), sqlpp::tvin_arg_t<decltype(row.gamma)>>::value, "result fields are accepted and not wrapped") ;
|
||||
}
|
||||
}
|
||||
for (const auto& row : db(select(all_of(t)).from(t).where(true)))
|
||||
{
|
||||
static_assert(std::is_same<decltype(sqlpp::tvin(row.alpha)), sqlpp::tvin_arg_t<decltype(row.alpha)>>::value,
|
||||
"result fields are accepted and not wrapped");
|
||||
static_assert(std::is_same<decltype(sqlpp::tvin(row.beta)), sqlpp::tvin_arg_t<decltype(row.beta)>>::value,
|
||||
"result fields are accepted and not wrapped");
|
||||
static_assert(std::is_same<decltype(sqlpp::tvin(row.gamma)), sqlpp::tvin_arg_t<decltype(row.gamma)>>::value,
|
||||
"result fields are accepted and not wrapped");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -30,52 +30,51 @@
|
||||
#include <sqlpp11/functions.h>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
int Insert(int, char**)
|
||||
{
|
||||
MockDb db;
|
||||
MockDb::_serializer_context_t printer;
|
||||
test::TabBar t;
|
||||
//test::TabFoo f;
|
||||
MockDb db;
|
||||
MockDb::_serializer_context_t printer;
|
||||
test::TabBar t;
|
||||
// test::TabFoo f;
|
||||
|
||||
{
|
||||
using T = decltype(insert_into(t));
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
{
|
||||
using T = decltype(insert_into(t));
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
{
|
||||
using T = decltype(insert_into(t).set(t.beta = "kirschauflauf"));
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
{
|
||||
using T = decltype(insert_into(t).set(t.beta = "kirschauflauf"));
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
{
|
||||
using T = decltype(dynamic_insert_into(db, t).dynamic_set());
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
{
|
||||
using T = decltype(dynamic_insert_into(db, t).dynamic_set());
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
db(insert_into(t).default_values());
|
||||
db(insert_into(t).set(t.gamma = true, t.beta = "kirschauflauf"));
|
||||
db(insert_into(t).default_values());
|
||||
db(insert_into(t).set(t.gamma = true, t.beta = "kirschauflauf"));
|
||||
|
||||
serialize(insert_into(t).default_values(), printer).str();
|
||||
serialize(insert_into(t).default_values(), printer).str();
|
||||
|
||||
serialize(insert_into(t), printer).str();
|
||||
serialize(insert_into(t).set(t.gamma = true, t.beta = "kirschauflauf"), printer).str();
|
||||
serialize(insert_into(t).columns(t.gamma, t.beta), printer).str();
|
||||
auto multi_insert = insert_into(t).columns(t.gamma, t.beta, t.delta);
|
||||
multi_insert.values.add(t.gamma = true, t.beta = "cheesecake", t.delta = 1);
|
||||
multi_insert.values.add(t.gamma = sqlpp::default_value, t.beta = sqlpp::default_value, t.delta = sqlpp::default_value);
|
||||
auto i = dynamic_insert_into(db, t).dynamic_set();
|
||||
i.insert_list.add(t.beta = "kirschauflauf");
|
||||
printer.reset();
|
||||
std::cerr << serialize(i, printer).str() << std::endl;
|
||||
serialize(insert_into(t), printer).str();
|
||||
serialize(insert_into(t).set(t.gamma = true, t.beta = "kirschauflauf"), printer).str();
|
||||
serialize(insert_into(t).columns(t.gamma, t.beta), printer).str();
|
||||
auto multi_insert = insert_into(t).columns(t.gamma, t.beta, t.delta);
|
||||
multi_insert.values.add(t.gamma = true, t.beta = "cheesecake", t.delta = 1);
|
||||
multi_insert.values.add(t.gamma = sqlpp::default_value, t.beta = sqlpp::default_value,
|
||||
t.delta = sqlpp::default_value);
|
||||
auto i = dynamic_insert_into(db, t).dynamic_set();
|
||||
i.insert_list.add(t.beta = "kirschauflauf");
|
||||
printer.reset();
|
||||
std::cerr << serialize(i, printer).str() << std::endl;
|
||||
|
||||
db(multi_insert);
|
||||
|
||||
db(multi_insert);
|
||||
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::verbatim<sqlpp::integer>("17+4")));
|
||||
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::null));
|
||||
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::default_value));
|
||||
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::tvin(0)));
|
||||
|
||||
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::verbatim<sqlpp::integer>("17+4")));
|
||||
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::null));
|
||||
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::default_value));
|
||||
db(insert_into(t).set(t.gamma = true, t.delta = sqlpp::tvin(0)));
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -31,166 +31,183 @@
|
||||
|
||||
int Interpret(int, char**)
|
||||
{
|
||||
MockDb db = {};
|
||||
MockDb::_serializer_context_t printer;
|
||||
MockDb db = {};
|
||||
MockDb::_serializer_context_t printer;
|
||||
|
||||
test::TabFoo f;
|
||||
test::TabBar t;
|
||||
select(t.alpha.as(t.beta));
|
||||
test::TabFoo f;
|
||||
test::TabBar t;
|
||||
select(t.alpha.as(t.beta));
|
||||
|
||||
serialize(insert_into(t).columns(t.beta, t.gamma), printer).str();
|
||||
{
|
||||
auto i = insert_into(t).columns(t.gamma, t.beta);
|
||||
i.values.add(t.gamma = true, t.beta = "cheesecake");
|
||||
serialize(i, printer).str();
|
||||
i.values.add(t.gamma = false, t.beta = sqlpp::tvin("coffee"));
|
||||
i.values.add(t.gamma = false, t.beta = sqlpp::tvin(std::string()));
|
||||
serialize(i, printer).str();
|
||||
i.values.add(t.gamma = sqlpp::default_value, t.beta = sqlpp::null);
|
||||
serialize(i, printer).str();
|
||||
}
|
||||
serialize(insert_into(t).columns(t.beta, t.gamma), printer).str();
|
||||
{
|
||||
auto i = insert_into(t).columns(t.gamma, t.beta);
|
||||
i.values.add(t.gamma = true, t.beta = "cheesecake");
|
||||
serialize(i, printer).str();
|
||||
i.values.add(t.gamma = false, t.beta = sqlpp::tvin("coffee"));
|
||||
i.values.add(t.gamma = false, t.beta = sqlpp::tvin(std::string()));
|
||||
serialize(i, printer).str();
|
||||
i.values.add(t.gamma = sqlpp::default_value, t.beta = sqlpp::null);
|
||||
serialize(i, printer).str();
|
||||
}
|
||||
|
||||
serialize(t.alpha = sqlpp::null, printer).str();
|
||||
serialize(t.alpha = sqlpp::default_value, printer).str();
|
||||
serialize(t.alpha, printer).str();
|
||||
serialize(-t.alpha, printer).str();
|
||||
serialize(+t.alpha, printer).str();
|
||||
serialize(-(t.alpha + 7), printer).str();
|
||||
serialize(t.alpha = 0, printer).str();
|
||||
serialize(t.alpha = sqlpp::tvin(0), printer).str();
|
||||
serialize(t.alpha == 0, printer).str();
|
||||
serialize(t.alpha == sqlpp::tvin(0), printer).str();
|
||||
serialize(t.alpha != 0, printer).str();
|
||||
serialize(t.gamma != sqlpp::tvin(false), printer).str();
|
||||
serialize(t.alpha == 7, printer).str();
|
||||
serialize(t.delta = sqlpp::tvin(0), printer).str();
|
||||
serialize(t.beta + "kaesekuchen", printer).str();
|
||||
serialize(t.alpha = sqlpp::null, printer).str();
|
||||
serialize(t.alpha = sqlpp::default_value, printer).str();
|
||||
serialize(t.alpha, printer).str();
|
||||
serialize(-t.alpha, printer).str();
|
||||
serialize(+t.alpha, printer).str();
|
||||
serialize(-(t.alpha + 7), printer).str();
|
||||
serialize(t.alpha = 0, printer).str();
|
||||
serialize(t.alpha = sqlpp::tvin(0), printer).str();
|
||||
serialize(t.alpha == 0, printer).str();
|
||||
serialize(t.alpha == sqlpp::tvin(0), printer).str();
|
||||
serialize(t.alpha != 0, printer).str();
|
||||
serialize(t.gamma != sqlpp::tvin(false), printer).str();
|
||||
serialize(t.alpha == 7, printer).str();
|
||||
serialize(t.delta = sqlpp::tvin(0), printer).str();
|
||||
serialize(t.beta + "kaesekuchen", printer).str();
|
||||
|
||||
serialize(sqlpp::select(), printer).str();
|
||||
serialize(sqlpp::select().flags(sqlpp::distinct), printer).str();
|
||||
serialize(select(t.alpha, t.beta).flags(sqlpp::distinct), printer).str();
|
||||
serialize(select(t.alpha, t.beta), printer).str();
|
||||
serialize(select(t.alpha, t.beta).from(t), printer).str();
|
||||
serialize(select(t.alpha, t.beta).from(t).where(t.alpha == 3), printer).str();
|
||||
serialize(select(t.alpha, t.beta).from(t).where(t.alpha == 3).group_by(t.gamma), printer).str();
|
||||
serialize(select(t.alpha, t.beta).from(t).where(t.alpha == 3).group_by(t.gamma).having(t.beta.like("%kuchen")), printer).str();
|
||||
serialize(select(t.alpha, t.beta).from(t).where(t.alpha == 3).group_by(t.gamma).having(t.beta.like("%kuchen")).order_by(t.beta.asc()), printer).str();
|
||||
serialize(select(t.alpha, t.beta).from(t).where(t.alpha == 3).group_by(t.gamma).having(t.beta.like("%kuchen")).order_by(t.beta.asc()).limit(17).offset(3), printer).str();
|
||||
serialize(sqlpp::select(), printer).str();
|
||||
serialize(sqlpp::select().flags(sqlpp::distinct), printer).str();
|
||||
serialize(select(t.alpha, t.beta).flags(sqlpp::distinct), printer).str();
|
||||
serialize(select(t.alpha, t.beta), printer).str();
|
||||
serialize(select(t.alpha, t.beta).from(t), printer).str();
|
||||
serialize(select(t.alpha, t.beta).from(t).where(t.alpha == 3), printer).str();
|
||||
serialize(select(t.alpha, t.beta).from(t).where(t.alpha == 3).group_by(t.gamma), printer).str();
|
||||
serialize(select(t.alpha, t.beta).from(t).where(t.alpha == 3).group_by(t.gamma).having(t.beta.like("%kuchen")),
|
||||
printer).str();
|
||||
serialize(select(t.alpha, t.beta)
|
||||
.from(t)
|
||||
.where(t.alpha == 3)
|
||||
.group_by(t.gamma)
|
||||
.having(t.beta.like("%kuchen"))
|
||||
.order_by(t.beta.asc()),
|
||||
printer).str();
|
||||
serialize(select(t.alpha, t.beta)
|
||||
.from(t)
|
||||
.where(t.alpha == 3)
|
||||
.group_by(t.gamma)
|
||||
.having(t.beta.like("%kuchen"))
|
||||
.order_by(t.beta.asc())
|
||||
.limit(17)
|
||||
.offset(3),
|
||||
printer).str();
|
||||
|
||||
serialize(parameter(sqlpp::bigint(), t.alpha), printer).str();
|
||||
serialize(parameter(t.alpha), printer).str();
|
||||
serialize(t.alpha == parameter(t.alpha), printer).str();
|
||||
serialize(t.alpha == parameter(t.alpha) and (t.beta + "gimmick").like(parameter(t.beta)), printer).str();
|
||||
serialize(parameter(sqlpp::bigint(), t.alpha), printer).str();
|
||||
serialize(parameter(t.alpha), printer).str();
|
||||
serialize(t.alpha == parameter(t.alpha), printer).str();
|
||||
serialize(t.alpha == parameter(t.alpha) and (t.beta + "gimmick").like(parameter(t.beta)), printer).str();
|
||||
|
||||
serialize(insert_into(t), printer).str();
|
||||
serialize(insert_into(f).default_values(), printer).str();
|
||||
serialize(insert_into(t).set(t.gamma = true), printer).str();
|
||||
//serialize(insert_into(t).set(t.gamma = sqlpp::tvin(false)), printer).str(); cannot test this since gamma cannot be null and a static assert is thrown
|
||||
serialize(insert_into(t), printer).str();
|
||||
serialize(insert_into(f).default_values(), printer).str();
|
||||
serialize(insert_into(t).set(t.gamma = true), printer).str();
|
||||
// serialize(insert_into(t).set(t.gamma = sqlpp::tvin(false)), printer).str(); cannot test this since gamma cannot be
|
||||
// null and a static assert is thrown
|
||||
|
||||
serialize(update(t), printer).str();
|
||||
serialize(update(t).set(t.gamma = true), printer).str();
|
||||
serialize(update(t).set(t.gamma = true).where(t.beta.in("kaesekuchen", "cheesecake")), printer).str();
|
||||
serialize(update(t), printer).str();
|
||||
serialize(update(t).set(t.gamma = true), printer).str();
|
||||
serialize(update(t).set(t.gamma = true).where(t.beta.in("kaesekuchen", "cheesecake")), printer).str();
|
||||
|
||||
serialize(remove_from(t), printer).str();
|
||||
serialize(remove_from(t).using_(t), printer).str();
|
||||
serialize(remove_from(t).where(t.alpha == sqlpp::tvin(0)), printer).str();
|
||||
serialize(remove_from(t).using_(t).where(t.alpha == sqlpp::tvin(0)), printer).str();
|
||||
serialize(remove_from(t), printer).str();
|
||||
serialize(remove_from(t).using_(t), printer).str();
|
||||
serialize(remove_from(t).where(t.alpha == sqlpp::tvin(0)), printer).str();
|
||||
serialize(remove_from(t).using_(t).where(t.alpha == sqlpp::tvin(0)), printer).str();
|
||||
|
||||
// functions
|
||||
serialize(sqlpp::value(7), printer).str();
|
||||
serialize(sqlpp::verbatim<sqlpp::integral>("irgendwas integrales"), printer).str();
|
||||
serialize(sqlpp::value_list(std::vector<int>({1,2,3,4,5,6,8})), printer).str();
|
||||
serialize(exists(select(t.alpha).from(t)), printer).str();
|
||||
serialize(any(select(t.alpha).from(t)), printer).str();
|
||||
serialize(some(select(t.alpha).from(t)), printer).str();
|
||||
serialize(count(t.alpha), printer).str();
|
||||
serialize(min(t.alpha), printer).str();
|
||||
serialize(max(t.alpha), printer).str();
|
||||
serialize(avg(t.alpha), printer).str();
|
||||
serialize(sum(t.alpha), printer).str();
|
||||
serialize(sqlpp::verbatim_table("whatever"), printer).str();
|
||||
// functions
|
||||
serialize(sqlpp::value(7), printer).str();
|
||||
serialize(sqlpp::verbatim<sqlpp::integral>("irgendwas integrales"), printer).str();
|
||||
serialize(sqlpp::value_list(std::vector<int>({1, 2, 3, 4, 5, 6, 8})), printer).str();
|
||||
serialize(exists(select(t.alpha).from(t)), printer).str();
|
||||
serialize(any(select(t.alpha).from(t)), printer).str();
|
||||
serialize(some(select(t.alpha).from(t)), printer).str();
|
||||
serialize(count(t.alpha), printer).str();
|
||||
serialize(min(t.alpha), printer).str();
|
||||
serialize(max(t.alpha), printer).str();
|
||||
serialize(avg(t.alpha), printer).str();
|
||||
serialize(sum(t.alpha), printer).str();
|
||||
serialize(sqlpp::verbatim_table("whatever"), printer).str();
|
||||
|
||||
// alias
|
||||
serialize(t.as(t.alpha), printer).str();
|
||||
serialize(t.as(t.alpha).beta, printer).str();
|
||||
// alias
|
||||
serialize(t.as(t.alpha), printer).str();
|
||||
serialize(t.as(t.alpha).beta, printer).str();
|
||||
|
||||
// select alias
|
||||
serialize(select(t.alpha).from(t).where(t.beta > "kaesekuchen").as(t.gamma), printer).str();
|
||||
// select alias
|
||||
serialize(select(t.alpha).from(t).where(t.beta > "kaesekuchen").as(t.gamma), printer).str();
|
||||
|
||||
serialize(t.alpha.is_null(), printer).str();
|
||||
serialize(t.alpha.is_null(), printer).str();
|
||||
|
||||
// join
|
||||
serialize(t.inner_join(t.as(t.alpha)).on(t.beta == t.as(t.alpha).beta), printer).str();
|
||||
{
|
||||
auto inner = t.inner_join(t.as(t.alpha)).on(t.beta == t.as(t.alpha).beta);
|
||||
serialize(select(t.alpha).from(inner), printer).str();
|
||||
}
|
||||
// join
|
||||
serialize(t.inner_join(t.as(t.alpha)).on(t.beta == t.as(t.alpha).beta), printer).str();
|
||||
{
|
||||
auto inner = t.inner_join(t.as(t.alpha)).on(t.beta == t.as(t.alpha).beta);
|
||||
serialize(select(t.alpha).from(inner), printer).str();
|
||||
}
|
||||
|
||||
// multi_column
|
||||
serialize(multi_column(t.alpha, (t.beta + "cake").as(t.gamma)).as(t.alpha), printer).str();
|
||||
serialize(multi_column(all_of(t)).as(t), printer).str();
|
||||
serialize(all_of(t).as(t), printer).str();
|
||||
// multi_column
|
||||
serialize(multi_column(t.alpha, (t.beta + "cake").as(t.gamma)).as(t.alpha), printer).str();
|
||||
serialize(multi_column(all_of(t)).as(t), printer).str();
|
||||
serialize(all_of(t).as(t), printer).str();
|
||||
|
||||
// dynamic select
|
||||
{
|
||||
auto s = dynamic_select(db).dynamic_flags().dynamic_columns().from(t);
|
||||
s.selected_columns.add(t.beta);
|
||||
s.selected_columns.add(t.gamma);
|
||||
serialize(s, printer).str();
|
||||
}
|
||||
{
|
||||
auto s = dynamic_select(db).dynamic_flags().dynamic_columns().from(t);
|
||||
s.select_flags.add(sqlpp::distinct);
|
||||
s.selected_columns.add(t.beta);
|
||||
s.selected_columns.add(t.gamma);
|
||||
serialize(s, printer).str();
|
||||
}
|
||||
{
|
||||
auto s = dynamic_select(db).dynamic_flags(sqlpp::distinct).dynamic_columns(t.alpha).extra_tables(t); // Would fail to run()
|
||||
s.select_flags.add(sqlpp::all);
|
||||
s.selected_columns.add(t.beta);
|
||||
s.selected_columns.add(t.gamma);
|
||||
serialize(s, printer).str();
|
||||
}
|
||||
// dynamic select
|
||||
{
|
||||
auto s = dynamic_select(db).dynamic_flags().dynamic_columns().from(t);
|
||||
s.selected_columns.add(t.beta);
|
||||
s.selected_columns.add(t.gamma);
|
||||
serialize(s, printer).str();
|
||||
}
|
||||
{
|
||||
auto s = dynamic_select(db).dynamic_flags().dynamic_columns().from(t);
|
||||
s.select_flags.add(sqlpp::distinct);
|
||||
s.selected_columns.add(t.beta);
|
||||
s.selected_columns.add(t.gamma);
|
||||
serialize(s, printer).str();
|
||||
}
|
||||
{
|
||||
auto s = dynamic_select(db)
|
||||
.dynamic_flags(sqlpp::distinct)
|
||||
.dynamic_columns(t.alpha)
|
||||
.extra_tables(t); // Would fail to run()
|
||||
s.select_flags.add(sqlpp::all);
|
||||
s.selected_columns.add(t.beta);
|
||||
s.selected_columns.add(t.gamma);
|
||||
serialize(s, printer).str();
|
||||
}
|
||||
|
||||
// distinct aggregate
|
||||
serialize(count(sqlpp::distinct, t.alpha % 7), printer).str();
|
||||
serialize(avg(sqlpp::distinct, t.alpha - 7), printer).str();
|
||||
serialize(sum(sqlpp::distinct, t.alpha + 7), printer).str();
|
||||
|
||||
// distinct aggregate
|
||||
serialize(count(sqlpp::distinct, t.alpha % 7), printer).str();
|
||||
serialize(avg(sqlpp::distinct, t.alpha - 7), printer).str();
|
||||
serialize(sum(sqlpp::distinct, t.alpha + 7), printer).str();
|
||||
serialize(select(all_of(t)).from(t).where(true), printer).str();
|
||||
serialize(select(all_of(t)).from(t).where(false), printer).str();
|
||||
|
||||
serialize(select(all_of(t)).from(t).where(true), printer).str();
|
||||
serialize(select(all_of(t)).from(t).where(false), printer).str();
|
||||
for (const auto& row : db(select(all_of(t)).from(t).where(true)))
|
||||
{
|
||||
serialize(row.alpha, printer);
|
||||
serialize(row.beta, printer);
|
||||
serialize(row.gamma, printer);
|
||||
}
|
||||
|
||||
for (const auto& row : db(select(all_of(t)).from(t).where(true)))
|
||||
{
|
||||
serialize(row.alpha, printer);
|
||||
serialize(row.beta, printer);
|
||||
serialize(row.gamma, printer);
|
||||
}
|
||||
get_sql_name(t);
|
||||
get_sql_name(t.alpha);
|
||||
|
||||
get_sql_name(t);
|
||||
get_sql_name(t.alpha);
|
||||
flatten(t.alpha == 7, db);
|
||||
|
||||
flatten(t.alpha == 7, db);
|
||||
auto x = boolean_expression(db, t.alpha == 7);
|
||||
x = sqlpp::boolean_expression<MockDb>(t.beta.like("%cheesecake"));
|
||||
x = x and boolean_expression(db, t.gamma);
|
||||
std::cerr << "----------------------------" << std::endl;
|
||||
printer.reset();
|
||||
std::cerr << serialize(x, printer).str() << std::endl;
|
||||
|
||||
auto x = boolean_expression(db, t.alpha == 7);
|
||||
x = sqlpp::boolean_expression<MockDb>(t.beta.like("%cheesecake"));
|
||||
x = x and boolean_expression(db, t.gamma);
|
||||
std::cerr << "----------------------------" << std::endl;
|
||||
printer.reset();
|
||||
std::cerr << serialize(x, printer).str() << std::endl;
|
||||
printer.reset();
|
||||
std::cerr << serialize(select(all_of(t)).from(t).where(t.alpha.in(select(f.epsilon).from(f).where(true))), printer)
|
||||
.str() << std::endl;
|
||||
|
||||
printer.reset();
|
||||
std::cerr << serialize(select(all_of(t)).from(t).where(t.alpha.in(select(f.epsilon).from(f).where(true))), printer).str() << std::endl;
|
||||
auto schema = db.attach("lorem");
|
||||
auto s = schema_qualified_table(schema, t).as(sqlpp::alias::x);
|
||||
|
||||
auto schema = db.attach("lorem");
|
||||
auto s = schema_qualified_table(schema, t).as(sqlpp::alias::x);
|
||||
printer.reset();
|
||||
std::cerr << serialize(select(all_of(s)).from(s).where(true), printer).str() << std::endl;
|
||||
|
||||
printer.reset();
|
||||
std::cerr << serialize(select(all_of(s)).from(s).where(true), printer).str() << std::endl;
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
int Minimalistic(int, char**)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
405
tests/MockDb.h
405
tests/MockDb.h
@@ -1,25 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
@@ -32,230 +32,227 @@
|
||||
#include <sqlpp11/serializer_context.h>
|
||||
#include <sqlpp11/connection.h>
|
||||
|
||||
template<bool enforceNullResultTreatment>
|
||||
struct MockDbT: public sqlpp::connection
|
||||
template <bool enforceNullResultTreatment>
|
||||
struct MockDbT : public sqlpp::connection
|
||||
{
|
||||
using _traits = ::sqlpp::make_traits<::sqlpp::no_value_t,
|
||||
::sqlpp::tag_if<::sqlpp::tag::enforce_null_result_treatment, enforceNullResultTreatment>
|
||||
>;
|
||||
using _traits =
|
||||
::sqlpp::make_traits<::sqlpp::no_value_t,
|
||||
::sqlpp::tag_if<::sqlpp::tag::enforce_null_result_treatment, enforceNullResultTreatment>>;
|
||||
|
||||
struct _serializer_context_t
|
||||
{
|
||||
std::ostringstream _os;
|
||||
struct _serializer_context_t
|
||||
{
|
||||
std::ostringstream _os;
|
||||
|
||||
_serializer_context_t() = default;
|
||||
_serializer_context_t(const _serializer_context_t& rhs)
|
||||
{
|
||||
_os << rhs._os.str();
|
||||
}
|
||||
_serializer_context_t() = default;
|
||||
_serializer_context_t(const _serializer_context_t& rhs)
|
||||
{
|
||||
_os << rhs._os.str();
|
||||
}
|
||||
|
||||
std::string str() const
|
||||
{
|
||||
return _os.str();
|
||||
}
|
||||
std::string str() const
|
||||
{
|
||||
return _os.str();
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
_os.str("");
|
||||
}
|
||||
void reset()
|
||||
{
|
||||
_os.str("");
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(T t)
|
||||
{
|
||||
return _os << t;
|
||||
}
|
||||
template <typename T>
|
||||
std::ostream& operator<<(T t)
|
||||
{
|
||||
return _os << t;
|
||||
}
|
||||
|
||||
static std::string escape(std::string arg)
|
||||
{
|
||||
return sqlpp::serializer_context_t::escape(arg);
|
||||
}
|
||||
};
|
||||
static std::string escape(std::string arg)
|
||||
{
|
||||
return sqlpp::serializer_context_t::escape(arg);
|
||||
}
|
||||
};
|
||||
|
||||
using _interpreter_context_t = _serializer_context_t;
|
||||
using _interpreter_context_t = _serializer_context_t;
|
||||
|
||||
_serializer_context_t get_serializer_context()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
_serializer_context_t get_serializer_context()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static _serializer_context_t& _serialize_interpretable(const T& t, _serializer_context_t& context)
|
||||
{
|
||||
sqlpp::serialize(t, context);
|
||||
return context;
|
||||
}
|
||||
template <typename T>
|
||||
static _serializer_context_t& _serialize_interpretable(const T& t, _serializer_context_t& context)
|
||||
{
|
||||
sqlpp::serialize(t, context);
|
||||
return context;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static _serializer_context_t& _interpret_interpretable(const T& t, _interpreter_context_t& context)
|
||||
{
|
||||
sqlpp::serialize(t, context);
|
||||
return context;
|
||||
}
|
||||
template <typename T>
|
||||
static _serializer_context_t& _interpret_interpretable(const T& t, _interpreter_context_t& context)
|
||||
{
|
||||
sqlpp::serialize(t, context);
|
||||
return context;
|
||||
}
|
||||
|
||||
class result_t
|
||||
{
|
||||
public:
|
||||
constexpr bool operator==(const result_t&) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
class result_t
|
||||
{
|
||||
public:
|
||||
constexpr bool operator==(const result_t&) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename ResultRow>
|
||||
void next(ResultRow& result_row)
|
||||
{
|
||||
result_row._invalidate();
|
||||
}
|
||||
};
|
||||
template <typename ResultRow>
|
||||
void next(ResultRow& result_row)
|
||||
{
|
||||
result_row._invalidate();
|
||||
}
|
||||
};
|
||||
|
||||
// Directly executed statements start here
|
||||
template<typename T>
|
||||
auto _run(const T& t, const std::true_type&) -> decltype(t._run(*this))
|
||||
{
|
||||
return t._run(*this);
|
||||
}
|
||||
// Directly executed statements start here
|
||||
template <typename T>
|
||||
auto _run(const T& t, const std::true_type&) -> decltype(t._run(*this))
|
||||
{
|
||||
return t._run(*this);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto _run(const T& t, const std::false_type&) -> decltype(t._run(*this));
|
||||
template <typename T>
|
||||
auto _run(const T& t, const std::false_type&) -> decltype(t._run(*this));
|
||||
|
||||
template<typename T>
|
||||
auto operator() (const T& t) -> decltype(t._run(*this))
|
||||
{
|
||||
sqlpp::run_check_t<T>::_();
|
||||
sqlpp::serialize_check_t<_serializer_context_t, T>::_();
|
||||
using _ok = sqlpp::logic::all_t<sqlpp::run_check_t<T>::type::value,
|
||||
sqlpp::serialize_check_t<_serializer_context_t, T>::type::value>;
|
||||
return _run(t, _ok{});
|
||||
}
|
||||
template <typename T>
|
||||
auto operator()(const T& t) -> decltype(t._run(*this))
|
||||
{
|
||||
sqlpp::run_check_t<T>::_();
|
||||
sqlpp::serialize_check_t<_serializer_context_t, T>::_();
|
||||
using _ok = sqlpp::logic::all_t<sqlpp::run_check_t<T>::type::value,
|
||||
sqlpp::serialize_check_t<_serializer_context_t, T>::type::value>;
|
||||
return _run(t, _ok{});
|
||||
}
|
||||
|
||||
size_t execute(const std::string&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
size_t execute(const std::string&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename Statement,
|
||||
typename Enable = typename std::enable_if<not std::is_convertible<Statement, std::string>::value, void>::type>
|
||||
size_t execute(const Statement& x)
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running execute call with\n" << context.str() << std::endl;
|
||||
return execute(context.str());
|
||||
}
|
||||
template <
|
||||
typename Statement,
|
||||
typename Enable = typename std::enable_if<not std::is_convertible<Statement, std::string>::value, void>::type>
|
||||
size_t execute(const Statement& x)
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running execute call with\n" << context.str() << std::endl;
|
||||
return execute(context.str());
|
||||
}
|
||||
|
||||
template<typename Insert>
|
||||
size_t insert(const Insert& x)
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running insert call with\n" << context.str() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
template <typename Insert>
|
||||
size_t insert(const Insert& x)
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running insert call with\n" << context.str() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename Update>
|
||||
size_t update(const Update& x)
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running update call with\n" << context.str() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
template <typename Update>
|
||||
size_t update(const Update& x)
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running update call with\n" << context.str() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename Remove>
|
||||
size_t remove(const Remove& x)
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running remove call with\n" << context.str() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
template <typename Remove>
|
||||
size_t remove(const Remove& x)
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running remove call with\n" << context.str() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename Select>
|
||||
result_t select(const Select& x)
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running select call with\n" << context.str() << std::endl;
|
||||
return {};
|
||||
}
|
||||
template <typename Select>
|
||||
result_t select(const Select& x)
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running select call with\n" << context.str() << std::endl;
|
||||
return {};
|
||||
}
|
||||
|
||||
// Prepared statements start here
|
||||
using _prepared_statement_t = std::nullptr_t;
|
||||
// Prepared statements start here
|
||||
using _prepared_statement_t = std::nullptr_t;
|
||||
|
||||
template<typename T>
|
||||
auto _prepare(const T& t, const std::true_type&) -> decltype(t._prepare(*this))
|
||||
{
|
||||
return t._prepare(*this);
|
||||
}
|
||||
template <typename T>
|
||||
auto _prepare(const T& t, const std::true_type&) -> decltype(t._prepare(*this))
|
||||
{
|
||||
return t._prepare(*this);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto _prepare(const T& t, const std::false_type&) -> decltype(t._prepare(*this));
|
||||
template <typename T>
|
||||
auto _prepare(const T& t, const std::false_type&) -> decltype(t._prepare(*this));
|
||||
|
||||
template<typename T>
|
||||
auto prepare(const T& t) -> decltype(t._prepare(*this))
|
||||
{
|
||||
sqlpp::prepare_check_t<T>::_();
|
||||
sqlpp::serialize_check_t<_serializer_context_t, T>::_();
|
||||
using _ok = sqlpp::logic::all_t<sqlpp::prepare_check_t<T>::type::value,
|
||||
sqlpp::serialize_check_t<_serializer_context_t, T>::type::value>;
|
||||
return _prepare(t, _ok{});
|
||||
}
|
||||
template <typename T>
|
||||
auto prepare(const T& t) -> decltype(t._prepare(*this))
|
||||
{
|
||||
sqlpp::prepare_check_t<T>::_();
|
||||
sqlpp::serialize_check_t<_serializer_context_t, T>::_();
|
||||
using _ok = sqlpp::logic::all_t<sqlpp::prepare_check_t<T>::type::value,
|
||||
sqlpp::serialize_check_t<_serializer_context_t, T>::type::value>;
|
||||
return _prepare(t, _ok{});
|
||||
}
|
||||
|
||||
template <typename Statement>
|
||||
_prepared_statement_t prepare_execute(Statement& x)
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running prepare execute call with\n" << context.str() << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<typename Statement>
|
||||
_prepared_statement_t prepare_execute(Statement& x)
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running prepare execute call with\n" << context.str() << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
template <typename Insert>
|
||||
_prepared_statement_t prepare_insert(Insert& x)
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running prepare insert call with\n" << context.str() << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<typename Insert>
|
||||
_prepared_statement_t prepare_insert(Insert& x)
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running prepare insert call with\n" << context.str() << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
template <typename PreparedExecute>
|
||||
size_t run_prepared_execute(const PreparedExecute&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename PreparedExecute>
|
||||
size_t run_prepared_execute(const PreparedExecute&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
template <typename PreparedInsert>
|
||||
size_t run_prepared_insert(const PreparedInsert&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename PreparedInsert>
|
||||
size_t run_prepared_insert(const PreparedInsert&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
template <typename Select>
|
||||
_prepared_statement_t prepare_select(Select& x)
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running prepare select call with\n" << context.str() << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<typename Select>
|
||||
_prepared_statement_t prepare_select(Select& x)
|
||||
{
|
||||
_serializer_context_t context;
|
||||
::sqlpp::serialize(x, context);
|
||||
std::cout << "Running prepare select call with\n" << context.str() << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<typename PreparedSelect>
|
||||
result_t run_prepared_select(PreparedSelect&)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
auto attach(std::string name)
|
||||
-> ::sqlpp::schema_t
|
||||
{
|
||||
return {name};
|
||||
}
|
||||
template <typename PreparedSelect>
|
||||
result_t run_prepared_select(PreparedSelect&)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
auto attach(std::string name) -> ::sqlpp::schema_t
|
||||
{
|
||||
return {name};
|
||||
}
|
||||
};
|
||||
|
||||
using MockDb = MockDbT<false>;
|
||||
using EnforceDb = MockDbT<true>;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -31,93 +31,112 @@
|
||||
|
||||
int Prepared(int, char**)
|
||||
{
|
||||
MockDb db = {};
|
||||
//test::TabFoo f;
|
||||
test::TabBar t;
|
||||
MockDb db = {};
|
||||
// test::TabFoo f;
|
||||
test::TabBar t;
|
||||
|
||||
// empty parameter lists
|
||||
{
|
||||
using P = sqlpp::make_parameter_list_t<decltype(t.alpha)>;
|
||||
static_assert(P::size::value == 0, "type requirement");
|
||||
}
|
||||
// empty parameter lists
|
||||
{
|
||||
using P = sqlpp::make_parameter_list_t<decltype(t.alpha)>;
|
||||
static_assert(P::size::value == 0, "type requirement");
|
||||
}
|
||||
|
||||
// single parameter
|
||||
{
|
||||
using P = sqlpp::make_parameter_list_t<decltype(parameter(t.alpha))>;
|
||||
static_assert(P::size::value == 1, "type requirement");
|
||||
auto p = P{};
|
||||
p.alpha = 7;
|
||||
}
|
||||
// single parameter
|
||||
{
|
||||
using P = sqlpp::make_parameter_list_t<decltype(parameter(t.alpha))>;
|
||||
static_assert(P::size::value == 1, "type requirement");
|
||||
auto p = P{};
|
||||
p.alpha = 7;
|
||||
}
|
||||
|
||||
// single parameter
|
||||
{
|
||||
using P = sqlpp::make_parameter_list_t<decltype(parameter(t.beta))>;
|
||||
static_assert(P::size::value == 1, "type requirement");
|
||||
auto p = P{};
|
||||
p.beta = "cheesecake";
|
||||
}
|
||||
// single parameter
|
||||
{
|
||||
using P = sqlpp::make_parameter_list_t<decltype(parameter(t.beta))>;
|
||||
static_assert(P::size::value == 1, "type requirement");
|
||||
auto p = P{};
|
||||
p.beta = "cheesecake";
|
||||
}
|
||||
|
||||
// single parameter in expression
|
||||
{
|
||||
using P = sqlpp::make_parameter_list_t<decltype(t.alpha == parameter(t.alpha))>;
|
||||
static_assert(P::size::value == 1, "type requirement");
|
||||
auto p = P{};
|
||||
p.alpha = 7;
|
||||
}
|
||||
// single parameter in expression
|
||||
{
|
||||
using P = sqlpp::make_parameter_list_t<decltype(t.alpha == parameter(t.alpha))>;
|
||||
static_assert(P::size::value == 1, "type requirement");
|
||||
auto p = P{};
|
||||
p.alpha = 7;
|
||||
}
|
||||
|
||||
// single parameter in larger expression
|
||||
{
|
||||
using P = sqlpp::make_parameter_list_t<decltype((t.beta.like("%") and t.alpha == parameter(t.alpha)) or
|
||||
t.gamma != false)>;
|
||||
static_assert(P::size::value == 1, "type requirement");
|
||||
auto p = P{};
|
||||
p.alpha = 7;
|
||||
}
|
||||
|
||||
// single parameter in larger expression
|
||||
{
|
||||
using P = sqlpp::make_parameter_list_t<decltype((t.beta.like("%") and t.alpha == parameter(t.alpha)) or t.gamma != false)>;
|
||||
static_assert(P::size::value == 1, "type requirement");
|
||||
auto p = P{};
|
||||
p.alpha = 7;
|
||||
}
|
||||
// three parameters in expression
|
||||
{
|
||||
using P = sqlpp::parameters_of<decltype((t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha)) or
|
||||
t.gamma != parameter(t.gamma))>;
|
||||
// FIXME: make some test, that does not depend on detail namespace, but still checks the correct order of the
|
||||
// parameters
|
||||
static_assert(std::is_same<P, sqlpp::detail::type_vector<decltype(parameter(t.beta)), decltype(parameter(t.alpha)),
|
||||
decltype(parameter(t.gamma))>>::value,
|
||||
"type requirement");
|
||||
}
|
||||
|
||||
// three parameters in expression
|
||||
{
|
||||
using P = sqlpp::parameters_of<decltype((t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha)) or t.gamma != parameter(t.gamma))>;
|
||||
// FIXME: make some test, that does not depend on detail namespace, but still checks the correct order of the parameters
|
||||
static_assert(std::is_same<P, sqlpp::detail::type_vector<decltype(parameter(t.beta)), decltype(parameter(t.alpha)),decltype(parameter(t.gamma))>>::value, "type requirement");
|
||||
}
|
||||
// OK, fine, now create a named parameter list from an expression
|
||||
{
|
||||
using Exp =
|
||||
decltype((t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha)) or t.gamma != parameter(t.gamma));
|
||||
using P = sqlpp::make_parameter_list_t<Exp>;
|
||||
P npl;
|
||||
static_assert(
|
||||
std::is_same<sqlpp::parameter_value_t<sqlpp::value_type_of<decltype(t.alpha)>>, decltype(npl.alpha)>::value,
|
||||
"type requirement");
|
||||
static_assert(
|
||||
std::is_same<sqlpp::parameter_value_t<sqlpp::value_type_of<decltype(t.beta)>>, decltype(npl.beta)>::value,
|
||||
"type requirement");
|
||||
static_assert(
|
||||
std::is_same<sqlpp::parameter_value_t<sqlpp::value_type_of<decltype(t.gamma)>>, decltype(npl.gamma)>::value,
|
||||
"type requirement");
|
||||
}
|
||||
|
||||
// OK, fine, now create a named parameter list from an expression
|
||||
{
|
||||
using Exp = decltype((t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha)) or t.gamma != parameter(t.gamma));
|
||||
using P = sqlpp::make_parameter_list_t<Exp>;
|
||||
P npl;
|
||||
static_assert(std::is_same<sqlpp::parameter_value_t<sqlpp::value_type_of<decltype(t.alpha)>>, decltype(npl.alpha)>::value, "type requirement");
|
||||
static_assert(std::is_same<sqlpp::parameter_value_t<sqlpp::value_type_of<decltype(t.beta)>>, decltype(npl.beta)>::value, "type requirement");
|
||||
static_assert(std::is_same<sqlpp::parameter_value_t<sqlpp::value_type_of<decltype(t.gamma)>>, decltype(npl.gamma)>::value, "type requirement");
|
||||
}
|
||||
// Wonderful, now take a look at the parameter list of a select
|
||||
{
|
||||
auto s = select(all_of(t)).from(t).where((t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha)) or
|
||||
t.gamma != parameter(t.gamma));
|
||||
auto p = db.prepare(s);
|
||||
p.params.alpha = 7;
|
||||
p.params.alpha = sqlpp::tvin(0);
|
||||
using S = decltype(s);
|
||||
using P = sqlpp::make_parameter_list_t<S>;
|
||||
P npl;
|
||||
|
||||
// Wonderful, now take a look at the parameter list of a select
|
||||
{
|
||||
auto s = select(all_of(t)).from(t).where((t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha)) or t.gamma != parameter(t.gamma));
|
||||
auto p = db.prepare(s);
|
||||
p.params.alpha = 7;
|
||||
p.params.alpha = sqlpp::tvin(0);
|
||||
using S = decltype(s);
|
||||
using P = sqlpp::make_parameter_list_t<S>;
|
||||
P npl;
|
||||
static_assert(
|
||||
std::is_same<sqlpp::parameter_value_t<sqlpp::value_type_of<decltype(t.alpha)>>, decltype(npl.alpha)>::value,
|
||||
"type requirement");
|
||||
static_assert(
|
||||
std::is_same<sqlpp::parameter_value_t<sqlpp::value_type_of<decltype(t.beta)>>, decltype(npl.beta)>::value,
|
||||
"type requirement");
|
||||
static_assert(
|
||||
std::is_same<sqlpp::parameter_value_t<sqlpp::value_type_of<decltype(t.gamma)>>, decltype(npl.gamma)>::value,
|
||||
"type requirement");
|
||||
npl.alpha = 7;
|
||||
auto x = npl;
|
||||
x = npl;
|
||||
std::cerr << x.alpha << std::endl;
|
||||
x = decltype(npl)();
|
||||
std::cerr << x.alpha << std::endl;
|
||||
}
|
||||
|
||||
static_assert(std::is_same<sqlpp::parameter_value_t<sqlpp::value_type_of<decltype(t.alpha)>>, decltype(npl.alpha)>::value, "type requirement");
|
||||
static_assert(std::is_same<sqlpp::parameter_value_t<sqlpp::value_type_of<decltype(t.beta)>>, decltype(npl.beta)>::value, "type requirement");
|
||||
static_assert(std::is_same<sqlpp::parameter_value_t<sqlpp::value_type_of<decltype(t.gamma)>>, decltype(npl.gamma)>::value, "type requirement");
|
||||
npl.alpha = 7;
|
||||
auto x = npl;
|
||||
x = npl;
|
||||
std::cerr << x.alpha << std::endl;
|
||||
x = decltype(npl)();
|
||||
std::cerr << x.alpha << std::endl;
|
||||
}
|
||||
// Check that a prepared select is default-constructable
|
||||
{
|
||||
auto s = select(all_of(t)).from(t).where((t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha)) or
|
||||
t.gamma != parameter(t.gamma));
|
||||
using P = decltype(db.prepare(s));
|
||||
P p;
|
||||
}
|
||||
|
||||
// Check that a prepared select is default-constructable
|
||||
{
|
||||
auto s = select(all_of(t)).from(t).where((t.beta.like(parameter(t.beta)) and t.alpha == parameter(t.alpha)) or t.gamma != parameter(t.gamma));
|
||||
using P = decltype(db.prepare(s));
|
||||
P p;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -29,41 +29,40 @@
|
||||
#include "MockDb.h"
|
||||
#include "is_regular.h"
|
||||
|
||||
|
||||
int Remove(int, char**)
|
||||
{
|
||||
MockDb db;
|
||||
MockDb::_serializer_context_t printer;
|
||||
MockDb db;
|
||||
MockDb::_serializer_context_t printer;
|
||||
|
||||
test::TabBar t;
|
||||
test::TabBar t;
|
||||
|
||||
{
|
||||
using T = decltype(remove_from(t));
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
{
|
||||
using T = decltype(remove_from(t));
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
{
|
||||
using T = decltype(remove_from(t).where(t.beta != "transparent"));
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
{
|
||||
using T = decltype(remove_from(t).where(t.beta != "transparent"));
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
{
|
||||
using T = decltype(dynamic_remove_from(db, t).dynamic_using().dynamic_where());
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
{
|
||||
using T = decltype(dynamic_remove_from(db, t).dynamic_using().dynamic_where());
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
serialize(remove_from(t), printer).str();
|
||||
serialize(remove_from(t).where(t.beta != "transparent"), printer).str();
|
||||
serialize(remove_from(t).using_(t), printer).str();
|
||||
auto r = dynamic_remove_from(db, t).dynamic_using().dynamic_where();
|
||||
r.using_.add(t);
|
||||
r.where.add(t.beta != "transparent");
|
||||
printer.reset();
|
||||
std::cerr << serialize(r, printer).str() << std::endl;
|
||||
printer.reset();
|
||||
std::cerr << serialize(remove_from(t).where(true), printer).str() << std::endl;
|
||||
serialize(remove_from(t), printer).str();
|
||||
serialize(remove_from(t).where(t.beta != "transparent"), printer).str();
|
||||
serialize(remove_from(t).using_(t), printer).str();
|
||||
auto r = dynamic_remove_from(db, t).dynamic_using().dynamic_where();
|
||||
r.using_.add(t);
|
||||
r.where.add(t.beta != "transparent");
|
||||
printer.reset();
|
||||
std::cerr << serialize(r, printer).str() << std::endl;
|
||||
printer.reset();
|
||||
std::cerr << serialize(remove_from(t).where(true), printer).str() << std::endl;
|
||||
|
||||
db(r);
|
||||
db(r);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -28,62 +28,63 @@
|
||||
#include "MockDb.h"
|
||||
#include <sqlpp11/sqlpp11.h>
|
||||
|
||||
|
||||
static_assert(not sqlpp::enforce_null_result_treatment_t<MockDb>::value, "MockDb interprets NULL as trivial");
|
||||
static_assert(sqlpp::enforce_null_result_treatment_t<EnforceDb>::value, "MockDb does not interpret NULL as trivial");
|
||||
|
||||
int Result(int, char**)
|
||||
{
|
||||
MockDb db = {};
|
||||
EnforceDb edb {};
|
||||
MockDb db = {};
|
||||
EnforceDb edb{};
|
||||
|
||||
test::TabBar t;
|
||||
test::TabBar t;
|
||||
|
||||
static_assert(sqlpp::can_be_null_t<decltype(t.alpha)>::value, "t.alpha can be null");
|
||||
static_assert(not sqlpp::null_is_trivial_value_t<decltype(t.alpha)>::value, "t.alpha does not say null_is_trivial");
|
||||
static_assert(sqlpp::can_be_null_t<decltype(t.alpha)>::value, "t.alpha can be null");
|
||||
static_assert(not sqlpp::null_is_trivial_value_t<decltype(t.alpha)>::value, "t.alpha does not say null_is_trivial");
|
||||
|
||||
// Using a non-enforcing db
|
||||
for (const auto& row : db(select(all_of(t), t.beta.like("")).from(t).where(true)))
|
||||
{
|
||||
static_assert(sqlpp::can_be_null_t<decltype(row.alpha)>::value, "row.alpha can be null");
|
||||
static_assert(sqlpp::null_is_trivial_value_t<decltype(row.alpha)>::value, "row.alpha interprets null_is_trivial");
|
||||
static_assert(std::is_same<bool, decltype(row.alpha.is_null())>::value, "Yikes");
|
||||
using T = sqlpp::wrap_operand_t<decltype(row.alpha)>;
|
||||
static_assert(sqlpp::can_be_null_t<T>::value, "row.alpha can be null");
|
||||
static_assert(sqlpp::is_result_field_t<T>::value, "result_fields are not wrapped");
|
||||
// Using a non-enforcing db
|
||||
for (const auto& row : db(select(all_of(t), t.beta.like("")).from(t).where(true)))
|
||||
{
|
||||
static_assert(sqlpp::can_be_null_t<decltype(row.alpha)>::value, "row.alpha can be null");
|
||||
static_assert(sqlpp::null_is_trivial_value_t<decltype(row.alpha)>::value, "row.alpha interprets null_is_trivial");
|
||||
static_assert(std::is_same<bool, decltype(row.alpha.is_null())>::value, "Yikes");
|
||||
using T = sqlpp::wrap_operand_t<decltype(row.alpha)>;
|
||||
static_assert(sqlpp::can_be_null_t<T>::value, "row.alpha can be null");
|
||||
static_assert(sqlpp::is_result_field_t<T>::value, "result_fields are not wrapped");
|
||||
|
||||
bool x = (t.alpha == row.alpha)._rhs._is_null();
|
||||
bool y = (t.alpha == row.alpha)._rhs._is_default();
|
||||
std::cerr << x << std::endl;
|
||||
std::cerr << y << std::endl;
|
||||
bool x = (t.alpha == row.alpha)._rhs._is_null();
|
||||
bool y = (t.alpha == row.alpha)._rhs._is_default();
|
||||
std::cerr << x << std::endl;
|
||||
std::cerr << y << std::endl;
|
||||
|
||||
for (const auto& sub : db(select(all_of(t)).from(t).where(t.alpha == row.alpha)))
|
||||
{
|
||||
std::cerr << sub.alpha << std::endl;
|
||||
}
|
||||
db(insert_into(t).set(t.beta = row.beta, t.gamma = false));
|
||||
}
|
||||
for (const auto& sub : db(select(all_of(t)).from(t).where(t.alpha == row.alpha)))
|
||||
{
|
||||
std::cerr << sub.alpha << std::endl;
|
||||
}
|
||||
db(insert_into(t).set(t.beta = row.beta, t.gamma = false));
|
||||
}
|
||||
|
||||
sqlpp::select((t.alpha + 1).as(t.alpha)).flags(sqlpp::all).from(t);
|
||||
for (const auto& row : db(select(all_of(t)).from(t).where(true)))
|
||||
{
|
||||
static_assert(sqlpp::can_be_null_t<decltype(row.alpha)>::value, "row.alpha can be null");
|
||||
static_assert(sqlpp::null_is_trivial_value_t<decltype(row.alpha)>::value, "row.alpha interprets null_is_trivial");
|
||||
}
|
||||
sqlpp::select((t.alpha + 1).as(t.alpha)).flags(sqlpp::all).from(t);
|
||||
for (const auto& row : db(select(all_of(t)).from(t).where(true)))
|
||||
{
|
||||
static_assert(sqlpp::can_be_null_t<decltype(row.alpha)>::value, "row.alpha can be null");
|
||||
static_assert(sqlpp::null_is_trivial_value_t<decltype(row.alpha)>::value, "row.alpha interprets null_is_trivial");
|
||||
}
|
||||
|
||||
// Using a non-enforcing db
|
||||
for (const auto& row : edb(select(all_of(t)).from(t).where(true)))
|
||||
{
|
||||
static_assert(sqlpp::can_be_null_t<decltype(row.alpha)>::value, "row.alpha can be null");
|
||||
static_assert(not sqlpp::null_is_trivial_value_t<decltype(row.alpha)>::value, "row.alpha interprets null_is_trivial");
|
||||
}
|
||||
// Using a non-enforcing db
|
||||
for (const auto& row : edb(select(all_of(t)).from(t).where(true)))
|
||||
{
|
||||
static_assert(sqlpp::can_be_null_t<decltype(row.alpha)>::value, "row.alpha can be null");
|
||||
static_assert(not sqlpp::null_is_trivial_value_t<decltype(row.alpha)>::value,
|
||||
"row.alpha interprets null_is_trivial");
|
||||
}
|
||||
|
||||
sqlpp::select((t.alpha + 1).as(t.alpha)).flags(sqlpp::all).from(t);
|
||||
for (const auto& row : edb(select(all_of(t)).from(t).where(true)))
|
||||
{
|
||||
static_assert(sqlpp::can_be_null_t<decltype(row.alpha)>::value, "row.alpha can be null");
|
||||
static_assert(not sqlpp::null_is_trivial_value_t<decltype(row.alpha)>::value, "row.alpha interprets null_is_trivial");
|
||||
}
|
||||
sqlpp::select((t.alpha + 1).as(t.alpha)).flags(sqlpp::all).from(t);
|
||||
for (const auto& row : edb(select(all_of(t)).from(t).where(true)))
|
||||
{
|
||||
static_assert(sqlpp::can_be_null_t<decltype(row.alpha)>::value, "row.alpha can be null");
|
||||
static_assert(not sqlpp::null_is_trivial_value_t<decltype(row.alpha)>::value,
|
||||
"row.alpha interprets null_is_trivial");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
168
tests/Sample.h
168
tests/Sample.h
@@ -13,15 +13,21 @@ namespace test
|
||||
{
|
||||
struct _alias_t
|
||||
{
|
||||
static constexpr const char _literal[] = "delta";
|
||||
static constexpr const char _literal[] = "delta";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
struct _member_t
|
||||
{
|
||||
T delta;
|
||||
T& operator()()
|
||||
{
|
||||
T delta;
|
||||
T& operator()() { return delta; }
|
||||
const T& operator()() const { return delta; }
|
||||
};
|
||||
return delta;
|
||||
}
|
||||
const T& operator()() const
|
||||
{
|
||||
return delta;
|
||||
}
|
||||
};
|
||||
};
|
||||
using _traits = sqlpp::make_traits<sqlpp::varchar, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
@@ -29,15 +35,21 @@ namespace test
|
||||
{
|
||||
struct _alias_t
|
||||
{
|
||||
static constexpr const char _literal[] = "epsilon";
|
||||
static constexpr const char _literal[] = "epsilon";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
struct _member_t
|
||||
{
|
||||
T epsilon;
|
||||
T& operator()()
|
||||
{
|
||||
T epsilon;
|
||||
T& operator()() { return epsilon; }
|
||||
const T& operator()() const { return epsilon; }
|
||||
};
|
||||
return epsilon;
|
||||
}
|
||||
const T& operator()() const
|
||||
{
|
||||
return epsilon;
|
||||
}
|
||||
};
|
||||
};
|
||||
using _traits = sqlpp::make_traits<sqlpp::bigint, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
@@ -45,35 +57,44 @@ namespace test
|
||||
{
|
||||
struct _alias_t
|
||||
{
|
||||
static constexpr const char _literal[] = "omega";
|
||||
static constexpr const char _literal[] = "omega";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
struct _member_t
|
||||
{
|
||||
T omega;
|
||||
T& operator()()
|
||||
{
|
||||
T omega;
|
||||
T& operator()() { return omega; }
|
||||
const T& operator()() const { return omega; }
|
||||
};
|
||||
return omega;
|
||||
}
|
||||
const T& operator()() const
|
||||
{
|
||||
return omega;
|
||||
}
|
||||
};
|
||||
};
|
||||
using _traits = sqlpp::make_traits<sqlpp::floating_point, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
}
|
||||
|
||||
struct TabFoo: sqlpp::table_t<TabFoo,
|
||||
TabFoo_::Delta,
|
||||
TabFoo_::Epsilon,
|
||||
TabFoo_::Omega>
|
||||
struct TabFoo : sqlpp::table_t<TabFoo, TabFoo_::Delta, TabFoo_::Epsilon, TabFoo_::Omega>
|
||||
{
|
||||
struct _alias_t
|
||||
{
|
||||
static constexpr const char _literal[] = "tab_foo";
|
||||
static constexpr const char _literal[] = "tab_foo";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
struct _member_t
|
||||
{
|
||||
T tabFoo;
|
||||
T& operator()() { return tabFoo; }
|
||||
const T& operator()() const { return tabFoo; }
|
||||
T& operator()()
|
||||
{
|
||||
return tabFoo;
|
||||
}
|
||||
const T& operator()() const
|
||||
{
|
||||
return tabFoo;
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -83,31 +104,44 @@ namespace test
|
||||
{
|
||||
struct _alias_t
|
||||
{
|
||||
static constexpr const char _literal[] = "alpha";
|
||||
static constexpr const char _literal[] = "alpha";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
struct _member_t
|
||||
{
|
||||
T alpha;
|
||||
T& operator()()
|
||||
{
|
||||
T alpha;
|
||||
T& operator()() { return alpha; }
|
||||
const T& operator()() const { return alpha; }
|
||||
};
|
||||
return alpha;
|
||||
}
|
||||
const T& operator()() const
|
||||
{
|
||||
return alpha;
|
||||
}
|
||||
};
|
||||
};
|
||||
using _traits = sqlpp::make_traits<sqlpp::bigint, sqlpp::tag::must_not_insert, sqlpp::tag::must_not_update, sqlpp::tag::can_be_null>;
|
||||
using _traits = sqlpp::
|
||||
make_traits<sqlpp::bigint, sqlpp::tag::must_not_insert, sqlpp::tag::must_not_update, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
struct Beta
|
||||
{
|
||||
struct _alias_t
|
||||
{
|
||||
static constexpr const char _literal[] = "beta";
|
||||
static constexpr const char _literal[] = "beta";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
struct _member_t
|
||||
{
|
||||
T beta;
|
||||
T& operator()()
|
||||
{
|
||||
T beta;
|
||||
T& operator()() { return beta; }
|
||||
const T& operator()() const { return beta; }
|
||||
};
|
||||
return beta;
|
||||
}
|
||||
const T& operator()() const
|
||||
{
|
||||
return beta;
|
||||
}
|
||||
};
|
||||
};
|
||||
using _traits = sqlpp::make_traits<sqlpp::varchar, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
@@ -115,15 +149,21 @@ namespace test
|
||||
{
|
||||
struct _alias_t
|
||||
{
|
||||
static constexpr const char _literal[] = "gamma";
|
||||
static constexpr const char _literal[] = "gamma";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
struct _member_t
|
||||
{
|
||||
T gamma;
|
||||
T& operator()()
|
||||
{
|
||||
T gamma;
|
||||
T& operator()() { return gamma; }
|
||||
const T& operator()() const { return gamma; }
|
||||
};
|
||||
return gamma;
|
||||
}
|
||||
const T& operator()() const
|
||||
{
|
||||
return gamma;
|
||||
}
|
||||
};
|
||||
};
|
||||
using _traits = sqlpp::make_traits<sqlpp::boolean, sqlpp::tag::require_insert>;
|
||||
};
|
||||
@@ -131,36 +171,44 @@ namespace test
|
||||
{
|
||||
struct _alias_t
|
||||
{
|
||||
static constexpr const char _literal[] = "delta";
|
||||
static constexpr const char _literal[] = "delta";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
struct _member_t
|
||||
{
|
||||
T delta;
|
||||
T& operator()()
|
||||
{
|
||||
T delta;
|
||||
T& operator()() { return delta; }
|
||||
const T& operator()() const { return delta; }
|
||||
};
|
||||
return delta;
|
||||
}
|
||||
const T& operator()() const
|
||||
{
|
||||
return delta;
|
||||
}
|
||||
};
|
||||
};
|
||||
using _traits = sqlpp::make_traits<sqlpp::integer, sqlpp::tag::can_be_null>;
|
||||
};
|
||||
}
|
||||
|
||||
struct TabBar: sqlpp::table_t<TabBar,
|
||||
TabBar_::Alpha,
|
||||
TabBar_::Beta,
|
||||
TabBar_::Gamma,
|
||||
TabBar_::Delta>
|
||||
struct TabBar : sqlpp::table_t<TabBar, TabBar_::Alpha, TabBar_::Beta, TabBar_::Gamma, TabBar_::Delta>
|
||||
{
|
||||
struct _alias_t
|
||||
{
|
||||
static constexpr const char _literal[] = "tab_bar";
|
||||
static constexpr const char _literal[] = "tab_bar";
|
||||
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
struct _member_t
|
||||
{
|
||||
T tabBar;
|
||||
T& operator()() { return tabBar; }
|
||||
const T& operator()() const { return tabBar; }
|
||||
T& operator()()
|
||||
{
|
||||
return tabBar;
|
||||
}
|
||||
const T& operator()() const
|
||||
{
|
||||
return tabBar;
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
172
tests/Select.cpp
172
tests/Select.cpp
@@ -32,100 +32,122 @@
|
||||
#include <sqlpp11/functions.h>
|
||||
#include <sqlpp11/connection.h>
|
||||
|
||||
|
||||
template<typename Db, typename Column>
|
||||
template <typename Db, typename Column>
|
||||
int64_t getColumn(Db&& db, const Column& column)
|
||||
{
|
||||
auto result = db(select(column.as(sqlpp::alias::a)).from(column.table()).where(true));
|
||||
if (not result.empty())
|
||||
return result.front().a;
|
||||
else
|
||||
return 0;
|
||||
auto result = db(select(column.as(sqlpp::alias::a)).from(column.table()).where(true));
|
||||
if (not result.empty())
|
||||
return result.front().a;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Select(int, char**)
|
||||
{
|
||||
MockDb db = {};
|
||||
MockDb::_serializer_context_t printer;
|
||||
MockDb db = {};
|
||||
MockDb::_serializer_context_t printer;
|
||||
|
||||
test::TabFoo f;
|
||||
test::TabBar t;
|
||||
const auto tab_a = f.as(sqlpp::alias::a);
|
||||
test::TabFoo f;
|
||||
test::TabBar t;
|
||||
const auto tab_a = f.as(sqlpp::alias::a);
|
||||
|
||||
getColumn(db, t.alpha);
|
||||
select(count(t.alpha));
|
||||
getColumn(db, t.alpha);
|
||||
select(count(t.alpha));
|
||||
|
||||
for (const auto& row : db(select(sqlpp::value(false).as(sqlpp::alias::a))))
|
||||
{
|
||||
std::cout << row.a << std::endl;
|
||||
}
|
||||
for (const auto& row : db(select(sqlpp::value(false).as(sqlpp::alias::a))))
|
||||
{
|
||||
std::cout << row.a << std::endl;
|
||||
}
|
||||
|
||||
for (const auto& row : db(select(all_of(t)).from(t).where(true)))
|
||||
{
|
||||
int64_t a = row.alpha;
|
||||
const std::string b = row.beta;
|
||||
std::cout << a << ", " << b << std::endl;
|
||||
}
|
||||
for (const auto& row : db(select(all_of(t)).from(t).where(true)))
|
||||
{
|
||||
int64_t a = row.alpha;
|
||||
const std::string b = row.beta;
|
||||
std::cout << a << ", " << b << std::endl;
|
||||
}
|
||||
|
||||
for (const auto& row : db(select(all_of(t).as(t)).from(t).where(true)))
|
||||
{
|
||||
int64_t a = row.tabBar.alpha;
|
||||
const std::string b = row.tabBar.beta;
|
||||
std::cout << a << ", " << b << std::endl;
|
||||
}
|
||||
for (const auto& row : db(select(all_of(t).as(t)).from(t).where(true)))
|
||||
{
|
||||
int64_t a = row.tabBar.alpha;
|
||||
const std::string b = row.tabBar.beta;
|
||||
std::cout << a << ", " << b << std::endl;
|
||||
}
|
||||
|
||||
for (const auto& row : db(select(all_of(t).as(t), t.gamma).from(t).where(t.alpha > 7)))
|
||||
{
|
||||
int64_t a = row.tabBar.alpha;
|
||||
const std::string b = row.tabBar.beta;
|
||||
const bool g = row.gamma;
|
||||
std::cout << a << ", " << b << ", " << g << std::endl;
|
||||
}
|
||||
for (const auto& row : db(select(all_of(t).as(t), t.gamma).from(t).where(t.alpha > 7)))
|
||||
{
|
||||
int64_t a = row.tabBar.alpha;
|
||||
const std::string b = row.tabBar.beta;
|
||||
const bool g = row.gamma;
|
||||
std::cout << a << ", " << b << ", " << g << std::endl;
|
||||
}
|
||||
|
||||
for (const auto& row : db(select(all_of(t), all_of(f)).from(t.join(f).on(t.alpha > f.omega and not t.gamma)).where(true)))
|
||||
{
|
||||
std::cout << row.alpha << std::endl;
|
||||
}
|
||||
for (const auto& row :
|
||||
db(select(all_of(t), all_of(f)).from(t.join(f).on(t.alpha > f.omega and not t.gamma)).where(true)))
|
||||
{
|
||||
std::cout << row.alpha << std::endl;
|
||||
}
|
||||
|
||||
for (const auto& row : db(select(all_of(t), all_of(f)).from(t.join(f).on(t.alpha > f.omega).join(tab_a).on(t.alpha == tab_a.omega)).where(true)))
|
||||
{
|
||||
std::cout << row.alpha << std::endl;
|
||||
}
|
||||
for (const auto& row : db(select(all_of(t), all_of(f))
|
||||
.from(t.join(f).on(t.alpha > f.omega).join(tab_a).on(t.alpha == tab_a.omega))
|
||||
.where(true)))
|
||||
{
|
||||
std::cout << row.alpha << std::endl;
|
||||
}
|
||||
|
||||
for (const auto& row : db(select(count(t.alpha), avg(t.alpha)).from(t).where(true)))
|
||||
{
|
||||
std::cout << row.count << std::endl;
|
||||
}
|
||||
for (const auto& row : db(select(count(t.alpha), avg(t.alpha)).from(t).where(true)))
|
||||
{
|
||||
std::cout << row.count << std::endl;
|
||||
}
|
||||
|
||||
for (const auto& row : db(select(count(t.alpha), avg(t.alpha)).from(t).where(t.alpha == sqlpp::tvin(0))))
|
||||
{
|
||||
std::cout << row.count << std::endl;
|
||||
}
|
||||
for (const auto& row : db(select(count(t.alpha), avg(t.alpha)).from(t).where(t.alpha == sqlpp::tvin(0))))
|
||||
{
|
||||
std::cout << row.count << std::endl;
|
||||
}
|
||||
|
||||
auto stat = sqlpp::select().columns(all_of(t)).flags(sqlpp::all).from(t).extra_tables(f,t).where(t.alpha > 0).group_by(t.alpha).order_by(t.gamma.asc()).having(t.gamma).limit(7).offset(19);
|
||||
auto stat = sqlpp::select()
|
||||
.columns(all_of(t))
|
||||
.flags(sqlpp::all)
|
||||
.from(t)
|
||||
.extra_tables(f, t)
|
||||
.where(t.alpha > 0)
|
||||
.group_by(t.alpha)
|
||||
.order_by(t.gamma.asc())
|
||||
.having(t.gamma)
|
||||
.limit(7)
|
||||
.offset(19);
|
||||
|
||||
auto s = dynamic_select(db).dynamic_columns(all_of(t)).dynamic_flags().dynamic_from(t).extra_tables(f,t).dynamic_where().dynamic_group_by(t.alpha).dynamic_order_by().dynamic_having(t.gamma).dynamic_limit().dynamic_offset();
|
||||
s.select_flags.add(sqlpp::distinct);
|
||||
s.selected_columns.add(f.omega);
|
||||
s.from.add(f);
|
||||
s.where.add(t.alpha > 7);
|
||||
s.having.add(t.alpha > 7);
|
||||
s.limit.set(3);
|
||||
s.offset.set(3);
|
||||
s.group_by.add(t.beta);
|
||||
s.order_by.add(t.beta.asc());
|
||||
for (const auto& row : db(s))
|
||||
{
|
||||
int64_t a = row.alpha;
|
||||
std::cout << a << std::endl;
|
||||
}
|
||||
auto s = dynamic_select(db)
|
||||
.dynamic_columns(all_of(t))
|
||||
.dynamic_flags()
|
||||
.dynamic_from(t)
|
||||
.extra_tables(f, t)
|
||||
.dynamic_where()
|
||||
.dynamic_group_by(t.alpha)
|
||||
.dynamic_order_by()
|
||||
.dynamic_having(t.gamma)
|
||||
.dynamic_limit()
|
||||
.dynamic_offset();
|
||||
s.select_flags.add(sqlpp::distinct);
|
||||
s.selected_columns.add(f.omega);
|
||||
s.from.add(f);
|
||||
s.where.add(t.alpha > 7);
|
||||
s.having.add(t.alpha > 7);
|
||||
s.limit.set(3);
|
||||
s.offset.set(3);
|
||||
s.group_by.add(t.beta);
|
||||
s.order_by.add(t.beta.asc());
|
||||
for (const auto& row : db(s))
|
||||
{
|
||||
int64_t a = row.alpha;
|
||||
std::cout << a << std::endl;
|
||||
}
|
||||
|
||||
printer.reset();
|
||||
std::cerr << serialize(s, printer).str() << std::endl;
|
||||
printer.reset();
|
||||
std::cerr << serialize(stat, printer).str() << std::endl;
|
||||
printer.reset();
|
||||
std::cerr << serialize(s, printer).str() << std::endl;
|
||||
printer.reset();
|
||||
std::cerr << serialize(stat, printer).str() << std::endl;
|
||||
|
||||
select(sqlpp::value(7).as(t.alpha));
|
||||
select(sqlpp::value(7).as(t.alpha));
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -32,356 +32,358 @@
|
||||
#include <sqlpp11/functions.h>
|
||||
#include <sqlpp11/connection.h>
|
||||
|
||||
|
||||
namespace alias
|
||||
{
|
||||
SQLPP_ALIAS_PROVIDER(a)
|
||||
SQLPP_ALIAS_PROVIDER(b)
|
||||
SQLPP_ALIAS_PROVIDER(left)
|
||||
SQLPP_ALIAS_PROVIDER(right)
|
||||
SQLPP_ALIAS_PROVIDER(a)
|
||||
SQLPP_ALIAS_PROVIDER(b)
|
||||
SQLPP_ALIAS_PROVIDER(left)
|
||||
SQLPP_ALIAS_PROVIDER(right)
|
||||
}
|
||||
|
||||
int SelectType(int, char**)
|
||||
{
|
||||
MockDb db = {};
|
||||
MockDb::_serializer_context_t printer;
|
||||
MockDb db = {};
|
||||
MockDb::_serializer_context_t printer;
|
||||
|
||||
test::TabFoo f;
|
||||
test::TabBar t;
|
||||
test::TabFoo f;
|
||||
test::TabBar t;
|
||||
|
||||
// Test a table
|
||||
{
|
||||
using T = decltype(t);
|
||||
static_assert(not sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
// Test a table
|
||||
{
|
||||
using T = decltype(t);
|
||||
static_assert(not sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test an alias of table
|
||||
{
|
||||
using T = decltype(t.as(alias::a));
|
||||
static_assert(not sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
// Test an alias of table
|
||||
{
|
||||
using T = decltype(t.as(alias::a));
|
||||
static_assert(not sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test an integral column of an alias of table
|
||||
{
|
||||
using T = decltype(t.as(alias::a).alpha);
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
// Test an integral column of an alias of table
|
||||
{
|
||||
using T = decltype(t.as(alias::a).alpha);
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test an integral table column
|
||||
{
|
||||
using T = decltype(t.alpha);
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test an integral table column
|
||||
{
|
||||
using T = decltype(t.alpha);
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_integral_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_floating_point_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
// Test a floating point table column
|
||||
{
|
||||
using T = decltype(f.omega);
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test a floating point table column
|
||||
{
|
||||
using T = decltype(f.omega);
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_integral_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_floating_point_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
// Test a an alias of a numeric table column
|
||||
{
|
||||
using T = decltype(t.alpha.as(alias::a));
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test a an alias of a numeric table column
|
||||
{
|
||||
using T = decltype(t.alpha.as(alias::a));
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
// Test a select of a single column without a from
|
||||
{
|
||||
using T = decltype(select(t.alpha));
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test a select of a single column without a from
|
||||
{
|
||||
using T = decltype(select(t.alpha));
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
// Test a select of a single numeric table column
|
||||
{
|
||||
using T = decltype(select(t.alpha).from(t));
|
||||
// static_assert(sqlpp::is_select_column_list_t<decltype(T::_column_list)>::value, "Must not be noop");
|
||||
// static_assert(sqlpp::is_from_t<decltype(T::_from)>::value, "Must not be noop");
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test a select of a single numeric table column
|
||||
{
|
||||
using T = decltype(select(t.alpha).from(t));
|
||||
//static_assert(sqlpp::is_select_column_list_t<decltype(T::_column_list)>::value, "Must not be noop");
|
||||
//static_assert(sqlpp::is_from_t<decltype(T::_from)>::value, "Must not be noop");
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
// Test a select of an alias of a single numeric table column
|
||||
{
|
||||
using T = decltype(select(t.alpha.as(alias::a)).from(t));
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test a select of an alias of a single numeric table column
|
||||
{
|
||||
using T = decltype(select(t.alpha.as(alias::a)).from(t));
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
// Test an alias of a select of a single numeric table column
|
||||
{
|
||||
using T = decltype(select(t.alpha).from(t).as(alias::b));
|
||||
static_assert(not sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "red to not be boolean");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test an alias of a select of a single numeric table column
|
||||
{
|
||||
using T = decltype(select(t.alpha).from(t).as(alias::b));
|
||||
static_assert(not sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "red to not be boolean");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
// Test the column of an alias of a select of an alias of a single numeric table column
|
||||
{
|
||||
using T = decltype(select(t.alpha.as(alias::a)).from(t).as(alias::b));
|
||||
static_assert(not sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test the column of an alias of a select of an alias of a single numeric table column
|
||||
{
|
||||
using T = decltype(select(t.alpha.as(alias::a)).from(t).as(alias::b));
|
||||
static_assert(not sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
// Test the column of an alias of a select of a single numeric table column
|
||||
{
|
||||
using T = decltype(select(t.alpha).from(t).as(alias::b).alpha);
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test the column of an alias of a select of a single numeric table column
|
||||
{
|
||||
using T = decltype(select(t.alpha).from(t).as(alias::b).alpha);
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
// Test an alias of a select of an alias of a single numeric table column
|
||||
{
|
||||
using T = decltype(select(t.alpha.as(alias::a)).from(t).as(alias::b).a);
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
// Test an alias of a select of an alias of a single numeric table column
|
||||
{
|
||||
using T = decltype(select(t.alpha.as(alias::a)).from(t).as(alias::b).a);
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_selectable_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::require_insert_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::must_not_insert_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::must_not_update_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_boolean_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_text_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_alias_t<T>::value, "type requirement");
|
||||
static_assert(not sqlpp::is_table_t<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
// Test that all_of(tab) is expanded in select
|
||||
{
|
||||
auto a = select(all_of(t));
|
||||
auto b = select(t.alpha, t.beta, t.gamma, t.delta);
|
||||
// auto c = select(t);
|
||||
static_assert(std::is_same<decltype(a), decltype(b)>::value, "all_of(t) has to be expanded by select()");
|
||||
// static_assert(std::is_same<decltype(b), decltype(c)>::value, "t has to be expanded by select()");
|
||||
}
|
||||
|
||||
// Test that all_of(tab) is expanded in select
|
||||
{
|
||||
auto a = select(all_of(t));
|
||||
auto b = select(t.alpha, t.beta, t.gamma, t.delta);
|
||||
//auto c = select(t);
|
||||
static_assert(std::is_same<decltype(a), decltype(b)>::value, "all_of(t) has to be expanded by select()");
|
||||
//static_assert(std::is_same<decltype(b), decltype(c)>::value, "t has to be expanded by select()");
|
||||
}
|
||||
// Test that all_of(tab) is expanded in multi_column
|
||||
{
|
||||
auto a = multi_column(all_of(t)).as(alias::a);
|
||||
auto b = multi_column(t.alpha, t.beta, t.gamma, t.delta).as(alias::a);
|
||||
static_assert(std::is_same<decltype(a), decltype(b)>::value, "all_of(t) has to be expanded by multi_column");
|
||||
}
|
||||
|
||||
// Test that all_of(tab) is expanded in multi_column
|
||||
{
|
||||
auto a = multi_column(all_of(t)).as(alias::a);
|
||||
auto b = multi_column(t.alpha, t.beta, t.gamma, t.delta).as(alias::a);
|
||||
static_assert(std::is_same<decltype(a), decltype(b)>::value, "all_of(t) has to be expanded by multi_column");
|
||||
}
|
||||
// Test that a multicolumn is not a value
|
||||
{
|
||||
auto m = multi_column(t.alpha, t.beta).as(alias::a);
|
||||
static_assert(not sqlpp::is_expression_t<decltype(m)>::value, "a multi_column is not a value");
|
||||
}
|
||||
|
||||
// Test that a multicolumn is not a value
|
||||
{
|
||||
auto m = multi_column(t.alpha, t.beta).as(alias::a);
|
||||
static_assert(not sqlpp::is_expression_t<decltype(m)>::value, "a multi_column is not a value");
|
||||
}
|
||||
// Test result field indices
|
||||
{
|
||||
using Select = decltype(select(all_of(t), // index 0, 1, 2, 3 (alpha, beta, gamma, delta)
|
||||
multi_column(all_of(t)).as(alias::left), // index 4 (including 4, 5, 6, 7)
|
||||
multi_column(all_of(t)).as(alias::right), // index 8 (including 8, 9, 10, 11)
|
||||
t.alpha.as(alias::a) // index 12
|
||||
)
|
||||
.from(t)
|
||||
.where(true)); // next index is 13
|
||||
using ResultRow = typename Select::_result_methods_t<Select>::template _result_row_t<MockDb>;
|
||||
using IndexSequence = ResultRow::_field_index_sequence;
|
||||
static_assert(std::is_same<IndexSequence, sqlpp::detail::field_index_sequence<13, 0, 1, 2, 3, 4, 8, 12>>::value,
|
||||
"invalid field sequence");
|
||||
}
|
||||
|
||||
// Test result field indices
|
||||
{
|
||||
using Select = decltype(select(
|
||||
all_of(t), // index 0, 1, 2, 3 (alpha, beta, gamma, delta)
|
||||
multi_column(all_of(t)).as(alias::left), // index 4 (including 4, 5, 6, 7)
|
||||
multi_column(all_of(t)).as(alias::right), // index 8 (including 8, 9, 10, 11)
|
||||
t.alpha.as(alias::a) // index 12
|
||||
).from(t).where(true)); // next index is 13
|
||||
using ResultRow = typename Select::_result_methods_t<Select>::template _result_row_t<MockDb>;
|
||||
using IndexSequence = ResultRow::_field_index_sequence;
|
||||
static_assert(std::is_same<IndexSequence, sqlpp::detail::field_index_sequence<13, 0, 1, 2, 3, 4, 8, 12>>::value, "invalid field sequence");
|
||||
}
|
||||
// Test that result sets with identical name/value combinations have identical types
|
||||
{
|
||||
auto a = select(t.alpha);
|
||||
auto b = select(f.epsilon.as(t.alpha));
|
||||
using A = typename decltype(a)::_result_row_t<MockDb>;
|
||||
using B = typename decltype(b)::_result_row_t<MockDb>;
|
||||
static_assert(
|
||||
std::is_same<sqlpp::value_type_of<decltype(t.alpha)>, sqlpp::value_type_of<decltype(f.epsilon)>>::value,
|
||||
"Two bigint columns must have identical base_value_type");
|
||||
static_assert(std::is_same<A, B>::value,
|
||||
"select with identical columns(name/value_type) need to have identical result_types");
|
||||
}
|
||||
|
||||
// Test that result sets with identical name/value combinations have identical types
|
||||
{
|
||||
auto a = select(t.alpha);
|
||||
auto b = select(f.epsilon.as(t.alpha));
|
||||
using A = typename decltype(a)::_result_row_t<MockDb>;
|
||||
using B = typename decltype(b)::_result_row_t<MockDb>;
|
||||
static_assert(std::is_same<
|
||||
sqlpp::value_type_of<decltype(t.alpha)>,
|
||||
sqlpp::value_type_of<decltype(f.epsilon)>>::value, "Two bigint columns must have identical base_value_type");
|
||||
static_assert(std::is_same<A, B>::value, "select with identical columns(name/value_type) need to have identical result_types");
|
||||
}
|
||||
for (const auto& row : db(select(all_of(t)).from(t).where(true)))
|
||||
{
|
||||
int64_t a = row.alpha;
|
||||
std::cout << a << std::endl;
|
||||
}
|
||||
|
||||
for (const auto& row : db(select(all_of(t)).from(t).where(true)))
|
||||
{
|
||||
int64_t a = row.alpha;
|
||||
std::cout << a << std::endl;
|
||||
}
|
||||
{
|
||||
auto s = dynamic_select(db, all_of(t)).dynamic_from().dynamic_where().dynamic_limit().dynamic_offset();
|
||||
s.from.add(t);
|
||||
s.where.add_ntc(t.alpha > 7 and t.alpha == any(select(t.alpha).from(t).where(t.alpha < 3)));
|
||||
s.limit.set(30);
|
||||
s.limit.set(3);
|
||||
std::cerr << "------------------------\n";
|
||||
serialize(s, printer).str();
|
||||
std::cerr << "------------------------\n";
|
||||
using T = decltype(s);
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
{
|
||||
auto s = dynamic_select(db, all_of(t)).dynamic_from().dynamic_where().dynamic_limit().dynamic_offset();
|
||||
s.from.add(t);
|
||||
s.where.add_ntc(t.alpha > 7 and t.alpha == any(select(t.alpha).from(t).where(t.alpha < 3)));
|
||||
s.limit.set(30);
|
||||
s.limit.set(3);
|
||||
std::cerr << "------------------------\n";
|
||||
serialize(s, printer).str();
|
||||
std::cerr << "------------------------\n";
|
||||
using T = decltype(s);
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
// Test that select can be called with zero columns if it is used with dynamic columns.
|
||||
{
|
||||
auto s = dynamic_select(db).dynamic_columns().extra_tables(t);
|
||||
s.selected_columns.add(t.alpha);
|
||||
serialize(s, printer).str();
|
||||
}
|
||||
|
||||
// Test that select can be called with zero columns if it is used with dynamic columns.
|
||||
{
|
||||
auto s = dynamic_select(db).dynamic_columns().extra_tables(t);
|
||||
s.selected_columns.add(t.alpha);
|
||||
serialize(s, printer).str();
|
||||
}
|
||||
// Test that verbatim_table compiles
|
||||
{
|
||||
auto s = select(t.alpha).from(sqlpp::verbatim_table("my_unknown_table"));
|
||||
serialize(s, printer).str();
|
||||
}
|
||||
|
||||
// Test that verbatim_table compiles
|
||||
{
|
||||
auto s = select(t.alpha).from(sqlpp::verbatim_table("my_unknown_table"));
|
||||
serialize(s, printer).str();
|
||||
}
|
||||
|
||||
|
||||
static_assert(sqlpp::is_select_flag_t<decltype(sqlpp::all)>::value, "sqlpp::all has to be a select_flag");
|
||||
static_assert(sqlpp::is_select_flag_t<decltype(sqlpp::all)>::value, "sqlpp::all has to be a select_flag");
|
||||
using T = sqlpp::wrap_operand<int>::type;
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "T has to be an expression");
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "T has to be numeric");
|
||||
static_assert(sqlpp::is_numeric_t<decltype(t.alpha)>::value, "TabBar.alpha has to be a numeric");
|
||||
((t.alpha + 7) + 4).asc();
|
||||
static_assert(sqlpp::is_boolean_t<decltype(t.gamma == t.gamma)>::value, "Comparison expression have to be boolean");
|
||||
!t.gamma;
|
||||
serialize(t.beta < "kaesekuchen", printer).str();
|
||||
serialize(t.beta + "hallenhalma", printer).str();
|
||||
static_assert(sqlpp::must_not_insert_t<decltype(t.alpha)>::value, "alpha must not be inserted");
|
||||
serialize(t.alpha, printer).str();
|
||||
std::cerr << "\n" << sizeof(test::TabBar) << std::endl;
|
||||
static_assert(sqlpp::is_selectable_t<decltype(t.alpha)>::value, "alpha should be a named expression");
|
||||
static_assert(sqlpp::is_selectable_t<decltype(t.alpha.as(alias::a))>::value, "an alias of alpha should be a named expression");
|
||||
static_assert(sqlpp::is_alias_t<decltype(t.alpha.as(alias::a))>::value, "an alias of alpha should be an alias");
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
static_assert(sqlpp::is_expression_t<T>::value, "T has to be an expression");
|
||||
static_assert(sqlpp::is_numeric_t<T>::value, "T has to be numeric");
|
||||
static_assert(sqlpp::is_numeric_t<decltype(t.alpha)>::value, "TabBar.alpha has to be a numeric");
|
||||
((t.alpha + 7) + 4).asc();
|
||||
static_assert(sqlpp::is_boolean_t<decltype(t.gamma == t.gamma)>::value, "Comparison expression have to be boolean");
|
||||
!t.gamma;
|
||||
serialize(t.beta < "kaesekuchen", printer).str();
|
||||
serialize(t.beta + "hallenhalma", printer).str();
|
||||
static_assert(sqlpp::must_not_insert_t<decltype(t.alpha)>::value, "alpha must not be inserted");
|
||||
serialize(t.alpha, printer).str();
|
||||
std::cerr << "\n" << sizeof(test::TabBar) << std::endl;
|
||||
static_assert(sqlpp::is_selectable_t<decltype(t.alpha)>::value, "alpha should be a named expression");
|
||||
static_assert(sqlpp::is_selectable_t<decltype(t.alpha.as(alias::a))>::value,
|
||||
"an alias of alpha should be a named expression");
|
||||
static_assert(sqlpp::is_alias_t<decltype(t.alpha.as(alias::a))>::value, "an alias of alpha should be an alias");
|
||||
|
||||
auto l = t.as(alias::left);
|
||||
auto r = select(t.gamma.as(alias::a)).from(t).where(t.gamma == true).as(alias::right);
|
||||
static_assert(sqlpp::is_boolean_t<decltype(select(t.gamma).from(t))>::value, "select(bool) has to be a bool");
|
||||
static_assert(sqlpp::is_boolean_t<decltype(select(r.a).from(r))>::value, "select(bool) has to be a bool");
|
||||
auto s1 = sqlpp::select().flags(sqlpp::distinct, sqlpp::straight_join).columns(l.alpha, l.beta, select(r.a).from(r))
|
||||
.from(r,t,l)
|
||||
.where(t.beta == "hello world" and select(t.gamma).from(t))// .as(alias::right))
|
||||
.group_by(l.gamma, r.a)
|
||||
.having(r.a != true)
|
||||
.order_by(l.beta.asc())
|
||||
.limit(17)
|
||||
.offset(3)
|
||||
.as(alias::a)
|
||||
;
|
||||
auto l = t.as(alias::left);
|
||||
auto r = select(t.gamma.as(alias::a)).from(t).where(t.gamma == true).as(alias::right);
|
||||
static_assert(sqlpp::is_boolean_t<decltype(select(t.gamma).from(t))>::value, "select(bool) has to be a bool");
|
||||
static_assert(sqlpp::is_boolean_t<decltype(select(r.a).from(r))>::value, "select(bool) has to be a bool");
|
||||
auto s1 = sqlpp::select()
|
||||
.flags(sqlpp::distinct, sqlpp::straight_join)
|
||||
.columns(l.alpha, l.beta, select(r.a).from(r))
|
||||
.from(r, t, l)
|
||||
.where(t.beta == "hello world" and select(t.gamma).from(t)) // .as(alias::right))
|
||||
.group_by(l.gamma, r.a)
|
||||
.having(r.a != true)
|
||||
.order_by(l.beta.asc())
|
||||
.limit(17)
|
||||
.offset(3)
|
||||
.as(alias::a);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -31,23 +31,29 @@
|
||||
|
||||
int Union(int, char**)
|
||||
{
|
||||
MockDb db;
|
||||
MockDb::_serializer_context_t printer;
|
||||
MockDb db;
|
||||
MockDb::_serializer_context_t printer;
|
||||
|
||||
test::TabBar t;
|
||||
test::TabFoo f;
|
||||
test::TabBar t;
|
||||
test::TabFoo f;
|
||||
|
||||
db(select(t.alpha).from(t).where(true)
|
||||
.union_distinct(select(f.epsilon.as(t.alpha)).from(f).where(true)));
|
||||
db(select(t.alpha).from(t).where(true)
|
||||
.union_all(select(f.epsilon.as(t.alpha)).from(f).where(true)));
|
||||
db(select(t.alpha).from(t).where(true).union_distinct(select(f.epsilon.as(t.alpha)).from(f).where(true)));
|
||||
db(select(t.alpha).from(t).where(true).union_all(select(f.epsilon.as(t.alpha)).from(f).where(true)));
|
||||
|
||||
auto u = select(t.alpha).from(t).where(true).union_all(select(f.epsilon.as(t.alpha)).from(f).where(true)).as(sqlpp::alias::u);
|
||||
auto u = select(t.alpha)
|
||||
.from(t)
|
||||
.where(true)
|
||||
.union_all(select(f.epsilon.as(t.alpha)).from(f).where(true))
|
||||
.as(sqlpp::alias::u);
|
||||
|
||||
db(select(all_of(u)).from(u).where(true).union_all(select(t.delta.as(t.alpha)).from(t).where(true)));
|
||||
db(select(u.alpha).from(u).where(true).union_all(select(t.delta.as(t.alpha)).from(t).where(true)));
|
||||
db(select(all_of(u)).from(u).where(true).union_all(select(t.delta.as(t.alpha)).from(t).where(true)));
|
||||
db(select(u.alpha).from(u).where(true).union_all(select(t.delta.as(t.alpha)).from(t).where(true)));
|
||||
|
||||
db(select(t.alpha).from(t).where(true).union_all(select(t.alpha).from(t).where(true)).union_all(select(t.alpha).from(t).where(true)));
|
||||
db(select(t.alpha)
|
||||
.from(t)
|
||||
.where(true)
|
||||
.union_all(select(t.alpha).from(t).where(true))
|
||||
.union_all(select(t.alpha).from(t).where(true)));
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -31,45 +31,44 @@
|
||||
|
||||
int Update(int, char**)
|
||||
{
|
||||
MockDb db;
|
||||
MockDb::_serializer_context_t printer;
|
||||
MockDb db;
|
||||
MockDb::_serializer_context_t printer;
|
||||
|
||||
test::TabBar t;
|
||||
//test::TabFoo f;
|
||||
test::TabBar t;
|
||||
// test::TabFoo f;
|
||||
|
||||
{
|
||||
using T = decltype(update(t));
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
{
|
||||
using T = decltype(update(t));
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
{
|
||||
using T = decltype(update(t).set(t.gamma = false).where(t.beta != "transparent"));
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
{
|
||||
using T = decltype(update(t).set(t.gamma = false).where(t.beta != "transparent"));
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
{
|
||||
using T = decltype(dynamic_update(db, t).dynamic_set(t.gamma = false).dynamic_where());
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
{
|
||||
using T = decltype(dynamic_update(db, t).dynamic_set(t.gamma = false).dynamic_where());
|
||||
static_assert(sqlpp::is_regular<T>::value, "type requirement");
|
||||
}
|
||||
|
||||
serialize(update(t), printer).str();
|
||||
serialize(update(t).set(t.gamma = false), printer).str();
|
||||
serialize(update(t).set(t.gamma = false).where(t.beta != "transparent"), printer).str();
|
||||
serialize(update(t).set(t.beta = "opaque").where(t.beta != t.beta), printer).str();
|
||||
auto u = dynamic_update(db, t).dynamic_set(t.gamma = false).dynamic_where();
|
||||
u.assignments.add(t.beta = "cannot update gamma a second time");
|
||||
u.where.add(t.gamma != false);
|
||||
printer.reset();
|
||||
std::cerr << serialize(u, printer).str() << std::endl;
|
||||
serialize(update(t), printer).str();
|
||||
serialize(update(t).set(t.gamma = false), printer).str();
|
||||
serialize(update(t).set(t.gamma = false).where(t.beta != "transparent"), printer).str();
|
||||
serialize(update(t).set(t.beta = "opaque").where(t.beta != t.beta), printer).str();
|
||||
auto u = dynamic_update(db, t).dynamic_set(t.gamma = false).dynamic_where();
|
||||
u.assignments.add(t.beta = "cannot update gamma a second time");
|
||||
u.where.add(t.gamma != false);
|
||||
printer.reset();
|
||||
std::cerr << serialize(u, printer).str() << std::endl;
|
||||
|
||||
db(u);
|
||||
db(u);
|
||||
|
||||
db(update(t).set(t.delta = sqlpp::verbatim<sqlpp::integer>("17+4")).where(true));
|
||||
db(update(t).set(t.delta = sqlpp::null).where(true));
|
||||
db(update(t).set(t.delta = sqlpp::default_value).where(true));
|
||||
db(update(t).set(t.delta = sqlpp::verbatim<sqlpp::integer>("17+4")).where(true));
|
||||
db(update(t).set(t.delta = sqlpp::null).where(true));
|
||||
db(update(t).set(t.delta = sqlpp::default_value).where(true));
|
||||
|
||||
db(update(t).set(t.delta += t.alpha * 2, t.beta += " and cake").where(true));
|
||||
db(update(t).set(t.delta += t.alpha * 2, t.beta += " and cake").where(true));
|
||||
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -31,22 +31,23 @@
|
||||
|
||||
int With(int, char**)
|
||||
{
|
||||
MockDb db;
|
||||
MockDb::_serializer_context_t printer;
|
||||
MockDb db;
|
||||
MockDb::_serializer_context_t printer;
|
||||
|
||||
const auto t = test::TabBar{};
|
||||
const auto t = test::TabBar{};
|
||||
|
||||
auto x = sqlpp::cte(sqlpp::alias::x).as(select(all_of(t)).from(t));
|
||||
auto x = sqlpp::cte(sqlpp::alias::x).as(select(all_of(t)).from(t));
|
||||
|
||||
db(with(x)(select(x.alpha).from(x).where(true)));
|
||||
db(with(x)(select(x.alpha).from(x).where(true)));
|
||||
|
||||
auto y0 = sqlpp::cte(sqlpp::alias::y).as(select(all_of(t)).from(t));
|
||||
auto y = y0.union_all(select(all_of(y0)).from(y0).where(false));
|
||||
auto y0 = sqlpp::cte(sqlpp::alias::y).as(select(all_of(t)).from(t));
|
||||
auto y = y0.union_all(select(all_of(y0)).from(y0).where(false));
|
||||
|
||||
std::cout << serialize(y, printer).str() << std::endl; printer.reset();
|
||||
std::cout << serialize(from_table(y), printer).str() << std::endl;
|
||||
std::cout << serialize(y, printer).str() << std::endl;
|
||||
printer.reset();
|
||||
std::cout << serialize(from_table(y), printer).str() << std::endl;
|
||||
|
||||
db(with(y)(select(y.alpha).from(y).where(true)));
|
||||
db(with(y)(select(y.alpha).from(y).where(true)));
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015, Roland Bock
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@@ -31,29 +31,30 @@
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
template<typename T>
|
||||
struct is_regular
|
||||
{
|
||||
template <typename T>
|
||||
struct is_regular
|
||||
{
|
||||
#if defined __clang__
|
||||
#if __has_feature(cxx_thread_local)
|
||||
#define SQLPP_TEST_NO_THROW_MOVE_CONSTRUCTIBLE // clang 3.2 has a problem with nothrow_constructibility (it also does not have thread_local support)
|
||||
#endif
|
||||
#if __has_feature(cxx_thread_local)
|
||||
#define SQLPP_TEST_NO_THROW_MOVE_CONSTRUCTIBLE // clang 3.2 has a problem with nothrow_constructibility (it also does
|
||||
// not have thread_local support)
|
||||
#endif
|
||||
#else
|
||||
#define SQLPP_TEST_NO_THROW_MOVE_CONSTRUCTIBLE
|
||||
#define SQLPP_TEST_NO_THROW_MOVE_CONSTRUCTIBLE
|
||||
#endif
|
||||
|
||||
static constexpr bool value = true
|
||||
static constexpr bool value =
|
||||
true
|
||||
#if defined SQLPP_TEST_NO_THROW_MOVE_CONSTRUCTIBLE
|
||||
and std::is_nothrow_move_constructible<T>::value
|
||||
and std::is_nothrow_move_constructible<T>::value
|
||||
#endif
|
||||
and std::is_move_assignable<T>::value // containers and strings are not noexcept_assignable
|
||||
and std::is_copy_constructible<T>::value
|
||||
and std::is_copy_assignable<T>::value
|
||||
// default constructor makes no sense
|
||||
// (not) equals would be possible
|
||||
// not sure about less
|
||||
;
|
||||
};
|
||||
and std::is_move_assignable<T>::value // containers and strings are not noexcept_assignable
|
||||
and std::is_copy_constructible<T>::value and std::is_copy_assignable<T>::value
|
||||
// default constructor makes no sense
|
||||
// (not) equals would be possible
|
||||
// not sure about less
|
||||
;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user