0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Re-animated all tests

This commit is contained in:
rbock 2014-01-18 20:58:51 +01:00
parent 87302fa27f
commit 24b44fae65
22 changed files with 105 additions and 156 deletions

View File

@ -63,14 +63,9 @@ namespace sqlpp
{
using _value_type = boolean;
_parameter_t(const std::true_type&):
_parameter_t():
_value(false),
_is_null(false)
{}
_parameter_t(const std::false_type&):
_value(false),
_is_null(false)
_is_null(true)
{}
_parameter_t(const _cpp_value_type& value):
@ -186,14 +181,14 @@ namespace sqlpp
vendor::binary_expression_t<Base, and_, typename _constraint<T>::type> operator and(T&& t) const
{
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
return { *static_cast<const Base*>(this), std::forward<T>(t) };
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
}
template<typename T>
vendor::binary_expression_t<Base, or_, typename _constraint<T>::type> operator or(T&& t) const
{
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
return { *static_cast<const Base*>(this), std::forward<T>(t) };
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
}
vendor::not_t<Base> operator not() const

View File

@ -53,7 +53,7 @@ namespace sqlpp
_parameter_t():
_value(0),
_is_null(false)
_is_null(true)
{}
_parameter_t(const _cpp_value_type& value):
@ -195,28 +195,28 @@ namespace sqlpp
vendor::binary_expression_t<Base, plus_, typename _constraint<T>::type> operator +(T&& t) const
{
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
return { *static_cast<const Base*>(this), std::forward<T>(t) };
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
}
template<typename T>
vendor::binary_expression_t<Base, minus_, typename _constraint<T>::type> operator -(T&& t) const
{
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
return { *static_cast<const Base*>(this), std::forward<T>(t) };
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
}
template<typename T>
vendor::binary_expression_t<Base, multiplies_, typename _constraint<T>::type> operator *(T&& t) const
{
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
return { *static_cast<const Base*>(this), std::forward<T>(t) };
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
}
template<typename T>
vendor::binary_expression_t<Base, divides_, typename _constraint<T>::type> operator /(T&& t) const
{
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
return { *static_cast<const Base*>(this), std::forward<T>(t) };
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
}
template<typename T>

View File

@ -51,14 +51,9 @@ namespace sqlpp
{
using _value_type = integral;
_parameter_t(const std::true_type&):
_parameter_t():
_value(0),
_is_null(false)
{}
_parameter_t(const std::false_type&):
_value(0),
_is_null(false)
_is_null(true)
{}
explicit _parameter_t(const _cpp_value_type& value):
@ -202,28 +197,28 @@ namespace sqlpp
vendor::binary_expression_t<Base, plus_<T>, typename _constraint<T>::type> operator +(T&& t) const
{
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
return { *static_cast<const Base*>(this), std::forward<T>(t) };
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
}
template<typename T>
vendor::binary_expression_t<Base, minus_<T>, typename _constraint<T>::type> operator -(T&& t) const
{
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
return { *static_cast<const Base*>(this), std::forward<T>(t) };
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
}
template<typename T>
vendor::binary_expression_t<Base, multiplies_<T>, typename _constraint<T>::type> operator *(T&& t) const
{
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
return { *static_cast<const Base*>(this), std::forward<T>(t) };
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
}
template<typename T>
vendor::binary_expression_t<Base, divides_, typename _constraint<T>::type> operator /(T&& t) const
{
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
return { *static_cast<const Base*>(this), std::forward<T>(t) };
return { *static_cast<const Base*>(this), {std::forward<T>(t)} };
}
template<typename T>

View File

@ -30,9 +30,9 @@
namespace sqlpp
{
struct serializer
struct serializer_t
{
serializer(std::ostream& os):
serializer_t(std::ostream& os):
_os(os)
{}

View File

@ -27,6 +27,7 @@
#ifndef SQLPP_H
#define SQLPP_H
#include <sqlpp11/alias_provider.h>
#include <sqlpp11/column_types.h>
#include <sqlpp11/insert.h>
#include <sqlpp11/remove.h>

View File

@ -51,14 +51,9 @@ namespace sqlpp
{
using _value_type = integral;
_parameter_t(const std::true_type&):
_parameter_t():
_value(""),
_is_null(false)
{}
_parameter_t(const std::false_type&):
_value(""),
_is_null(false)
_is_null(true)
{}
_parameter_t(const _cpp_value_type& value):

View File

@ -39,7 +39,7 @@ namespace sqlpp
struct concat_t: public First::_value_type::template operators<concat_t<First, Args...>>
{
static_assert(sizeof...(Args) > 0, "concat requires two arguments at least");
using _valid_args = typename detail::make_set_if_not<is_text_t, First, Args...>::type;
using _valid_args = typename ::sqlpp::detail::make_set_if_not<is_text_t, First, Args...>::type;
static_assert(_valid_args::size::value == 0, "at least one non-text argument detected in concat()");
struct _value_type: public First::_value_type::_base_value_type

View File

@ -84,14 +84,14 @@ namespace sqlpp
static_assert(_is_dynamic::value or sizeof...(Assignments), "at least one select expression required in set()");
// check for duplicate assignments
static_assert(not detail::has_duplicates<Assignments...>::value, "at least one duplicate argument detected in set()");
static_assert(not ::sqlpp::detail::has_duplicates<Assignments...>::value, "at least one duplicate argument detected in set()");
// check for invalid assignments
using _assignment_set = typename detail::make_set_if<is_assignment_t, Assignments...>::type;
using _assignment_set = typename ::sqlpp::detail::make_set_if<is_assignment_t, Assignments...>::type;
static_assert(_assignment_set::size::value == sizeof...(Assignments), "at least one argument is not an assignment in set()");
// check for prohibited assignments
using _prohibited_assignment_set = typename detail::make_set_if<must_not_insert_t, typename Assignments::column_type...>::type;
using _prohibited_assignment_set = typename ::sqlpp::detail::make_set_if<must_not_insert_t, typename Assignments::column_type...>::type;
static_assert(_prohibited_assignment_set::size::value == 0, "at least one assignment is prohibited by its column definition in set()");
insert_list_t(Assignments... assignment):

View File

@ -30,6 +30,7 @@
#include <memory>
#include <sqlpp11/serializer.h>
#include <sqlpp11/parameter_list.h>
#include <sqlpp11/interpret.h>
namespace sqlpp
{
@ -38,7 +39,7 @@ namespace sqlpp
template<typename Db>
struct interpretable_t
{
using _context_t = typename Db::context;
using _context_t = typename Db::_context_t;
template<typename T>
interpretable_t(T t):
@ -51,7 +52,7 @@ namespace sqlpp
interpretable_t& operator=(interpretable_t&&) = default;
~interpretable_t() = default;
sqlpp::serializer& interpret(sqlpp::serializer& context) const
sqlpp::serializer_t& interpret(sqlpp::serializer_t& context) const
{
return _impl->interpret(context);
}
@ -64,8 +65,8 @@ namespace sqlpp
private:
struct _impl_base
{
virtual sqlpp::serializer& interpret(sqlpp::serializer& context) const = 0;
virtual _context_t interpret(_context_t& context) const = 0;
virtual sqlpp::serializer_t& interpret(sqlpp::serializer_t& context) const = 0;
virtual _context_t& interpret(_context_t& context) const = 0;
};
template<typename T>
@ -80,7 +81,7 @@ namespace sqlpp
_t(std::move(t))
{}
sqlpp::serializer& interpret(sqlpp::serializer& context) const
sqlpp::serializer_t& interpret(sqlpp::serializer_t& context) const
{
sqlpp::interpret(_t, context);
return context;

View File

@ -91,7 +91,7 @@ namespace sqlpp
context << separator;
first = false;
}
interpret(t, context);
interpret(entry, context);
}
return context;
}

View File

@ -40,6 +40,7 @@ namespace sqlpp
{
static_assert(is_text_t<Operand>::value, "Operand for like() has to be a text");
static_assert(is_text_t<Pattern>::value, "Pattern for like() has to be a text");
using _parameter_tuple_t = std::tuple<Operand, Pattern>;
struct _value_type: public boolean
{

View File

@ -38,7 +38,7 @@ namespace sqlpp
template<typename Db>
struct named_interpretable_t
{
using _context_t = typename Db::context;
using _context_t = typename Db::_context_t;
template<typename T>
named_interpretable_t(T t):
@ -51,7 +51,7 @@ namespace sqlpp
named_interpretable_t& operator=(named_interpretable_t&&) = default;
~named_interpretable_t() = default;
sqlpp::serializer& interpret(sqlpp::serializer& context) const
sqlpp::serializer_t& interpret(sqlpp::serializer_t& context) const
{
return _impl->interpret(context);
}
@ -69,7 +69,7 @@ namespace sqlpp
private:
struct _impl_base
{
virtual sqlpp::serializer& interpret(sqlpp::serializer& context) const = 0;
virtual sqlpp::serializer_t& interpret(sqlpp::serializer_t& context) const = 0;
virtual _context_t& interpret(_context_t& context) const = 0;
virtual std::string _get_name() const = 0;
};
@ -86,7 +86,7 @@ namespace sqlpp
_t(std::move(t))
{}
sqlpp::serializer& interpret(sqlpp::serializer& context) const
sqlpp::serializer_t& interpret(sqlpp::serializer_t& context) const
{
sqlpp::interpret(_t, context);
return context;

View File

@ -135,9 +135,6 @@ namespace sqlpp
using _is_dynamic = typename std::conditional<std::is_same<Database, void>::value, std::false_type, std::true_type>::type;
using _parameter_tuple_t = std::tuple<NamedExpr...>;
// check for at least one expression
static_assert(_is_dynamic::value or sizeof...(NamedExpr), "at least one select expression required");
// check for duplicate select expressions
static_assert(not ::sqlpp::detail::has_duplicates<NamedExpr...>::value, "at least one duplicate argument detected");
@ -191,6 +188,9 @@ namespace sqlpp
static Context& _(const T& t, Context& context)
{
// check for at least one expression
static_assert(T::_is_dynamic::value or sizeof...(NamedExpr), "at least one select expression required");
interpret_tuple(t._expressions, ',', context);
if (sizeof...(NamedExpr) and not t._dynamic_expressions.empty())
context << ',';

View File

@ -4,10 +4,10 @@ macro (build_and_run arg)
endmacro ()
build_and_run(InterpretTest)
#build_and_run(InsertTest)
#build_and_run(RemoveTest)
#build_and_run(UpdateTest)
#build_and_run(SelectTest)
#build_and_run(FunctionTest)
#build_and_run(PreparedTest)
build_and_run(InsertTest)
build_and_run(RemoveTest)
build_and_run(UpdateTest)
build_and_run(SelectTest)
build_and_run(FunctionTest)
build_and_run(PreparedTest)

View File

@ -25,6 +25,7 @@
#include "TabSample.h"
#include "MockDb.h"
#include <sqlpp11/alias_provider.h>
#include <sqlpp11/select.h>
#include <sqlpp11/functions.h>
#include <sqlpp11/connection.h>
@ -32,7 +33,7 @@
#include <iostream>
DbMock db = {};
SQLPP_ALIAS_PROVIDER_GENERATOR(kaesekuchen);
SQLPP_ALIAS_PROVIDER(kaesekuchen);
int main()
{

View File

@ -30,6 +30,7 @@
#include <iostream>
DbMock db;
DbMock::_context_t printer(std::cerr);
int main()
{
@ -56,11 +57,11 @@ int main()
static_assert(sqlpp::is_regular<T>::value, "type requirement");
}
insert_into(t).serialize(std::cerr, db); std::cerr << "\n";
insert_into(t).set(t.beta = "kirschauflauf").serialize(std::cerr, db); std::cerr << "\n";
interpret(insert_into(t), printer).flush();
interpret(insert_into(t).set(t.beta = "kirschauflauf"), printer).flush();
auto i = dynamic_insert_into(db, t).dynamic_set();
i = i.add_set(t.beta = "kirschauflauf");
i.serialize(std::cerr, db); std::cerr << "\n";
interpret(i, printer).flush();
return 0;
}

View File

@ -35,7 +35,7 @@
#include <iostream>
DbMock db = {};
DbMock::context printer(std::cerr);
DbMock::_context_t printer(std::cerr);
SQLPP_ALIAS_PROVIDER(kaesekuchen);
int main()

View File

@ -27,66 +27,14 @@
#define SQLPP_MOCK_DB_H
#include <sqlpp11/connection.h>
#include <sqlpp11/serializer.h>
class DbMock: public sqlpp::connection
struct DbMock: public sqlpp::connection
{
public:
struct context
struct _context_t : public sqlpp::serializer_t
{
using _database_t = DbMock;
context(std::ostream& os):
_os(os)
{}
template<typename T>
std::ostream& operator<<(T t)
{
return _os << t;
}
void flush()
{
_os << std::endl;
}
std::string escape(std::string arg)
{
return arg;
}
std::ostream& _os;
_context_t(std::ostream& os): sqlpp::serializer_t(os) {}
};
// join types
static constexpr bool _supports_inner_join = true;
static constexpr bool _supports_outer_join = true;
static constexpr bool _supports_left_outer_join = true;
static constexpr bool _supports_right_outer_join = true;
// functions
static constexpr bool _supports_avg = true;
static constexpr bool _supports_count = true;
static constexpr bool _supports_exists = true;
static constexpr bool _supports_like = true;
static constexpr bool _supports_in = true;
static constexpr bool _supports_max = true;
static constexpr bool _supports_min = true;
static constexpr bool _supports_not_in = true;
static constexpr bool _supports_sum = true;
// select
static constexpr bool _supports_group_by = true;
static constexpr bool _supports_having = true;
static constexpr bool _supports_limit = true;
static constexpr bool _supports_order_by = true;
static constexpr bool _supports_select_as_table = true;
static constexpr bool _supports_some = true;
static constexpr bool _supports_any = true;
static constexpr bool _use_concat_operator = true;
static constexpr bool _use_concat_function = true;
const std::string& escape(const std::string& text) { return text; }
};
#endif

View File

@ -87,7 +87,7 @@ int main()
// Wonderful, now take a look at the parameter list of a select
{
auto s = select(all_of(t)).from(t).where(t.beta.like(where_parameter(t.beta)) and t.alpha == where_parameter(t.alpha) or t.gamma != parameter(t.gamma));
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 S = decltype(s);
using T = sqlpp::make_parameter_list_t<S>::type;
T npl;

View File

@ -32,6 +32,7 @@
DbMock db;
DbMock::_context_t printer(std::cerr);
int main()
{
@ -56,13 +57,13 @@ int main()
static_assert(sqlpp::is_regular<T>::value, "type requirement");
}
remove_from(t).serialize(std::cerr, db); std::cerr << "\n";
remove_from(t).where(t.beta != "transparent").serialize(std::cerr, db); std::cerr << "\n";
remove_from(t).using_(t).serialize(std::cerr, db); std::cerr << "\n";
interpret(remove_from(t), printer).flush();
interpret(remove_from(t).where(t.beta != "transparent"), printer).flush();
interpret(remove_from(t).using_(t), printer).flush();
auto r = dynamic_remove_from(db, t).dynamic_using_().dynamic_where();
r = r.add_using_(t);
r = r.add_where(t.beta != "transparent");
r.serialize(std::cerr, db); std::cerr << "\n";
interpret(r, printer).flush();
return 0;
}

View File

@ -26,6 +26,7 @@
#include "TabSample.h"
#include "MockDb.h"
#include "is_regular.h"
#include <sqlpp11/alias_provider.h>
#include <sqlpp11/select.h>
#include <sqlpp11/functions.h>
#include <sqlpp11/connection.h>
@ -33,6 +34,15 @@
#include <iostream>
DbMock db = {};
DbMock::_context_t printer(std::cerr);
namespace alias
{
SQLPP_ALIAS_PROVIDER(a);
SQLPP_ALIAS_PROVIDER(b);
SQLPP_ALIAS_PROVIDER(left);
SQLPP_ALIAS_PROVIDER(right);
}
int main()
{
@ -59,7 +69,7 @@ int main()
// Test an alias of table
{
using T = decltype(t.as(sqlpp::alias::a));
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");
@ -77,7 +87,7 @@ int main()
// Test an integral column of an alias of table
{
using T = decltype(t.as(sqlpp::alias::a).alpha);
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");
@ -132,7 +142,7 @@ int main()
// Test a an alias of a numeric table column
{
using T = decltype(t.alpha.as(sqlpp::alias::a));
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_named_expression_t<T>::value, "type requirement");
@ -180,7 +190,7 @@ int main()
// Test a select of an alias of a single numeric table column
{
using T = decltype(select(t.alpha.as(sqlpp::alias::a)).from(t));
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_named_expression_t<T>::value, "type requirement");
@ -196,7 +206,7 @@ int main()
// Test an alias of a select of a single numeric table column
{
using T = decltype(select(t.alpha).from(t).as(sqlpp::alias::b));
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_named_expression_t<T>::value, "type requirement");
@ -212,7 +222,7 @@ int main()
// 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(sqlpp::alias::a)).from(t).as(sqlpp::alias::b));
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_named_expression_t<T>::value, "type requirement");
@ -228,7 +238,7 @@ int main()
// Test the column of an alias of a select of a single numeric table column
{
using T = decltype(select(t.alpha).from(t).as(sqlpp::alias::b).alpha);
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_named_expression_t<T>::value, "type requirement");
@ -244,7 +254,7 @@ int main()
// Test an alias of a select of an alias of a single numeric table column
{
using T = decltype(select(t.alpha.as(sqlpp::alias::a)).from(t).as(sqlpp::alias::b).a);
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_named_expression_t<T>::value, "type requirement");
@ -269,22 +279,22 @@ int main()
// Test that select(all_of(tab)) is expanded in multi_column
{
auto a = multi_column(sqlpp::alias::a, all_of(t));
auto b = multi_column(sqlpp::alias::a, t.alpha, t.beta, t.gamma);
auto a = multi_column(alias::a, all_of(t));
auto b = multi_column(alias::a, t.alpha, t.beta, t.gamma);
static_assert(std::is_same<decltype(a), decltype(b)>::value, "all_of(t) has to be expanded by multi_column");
}
// Test that select(tab) is expanded in multi_column
{
auto a = multi_column(sqlpp::alias::a, all_of(t));
auto b = multi_column(sqlpp::alias::a, t.alpha, t.beta, t.gamma);
auto a = multi_column(alias::a, all_of(t));
auto b = multi_column(alias::a, t.alpha, t.beta, t.gamma);
static_assert(std::is_same<decltype(a), decltype(b)>::value, "t has to be expanded by multi_column");
}
// Test that a multicolumn is not a value
{
auto m = multi_column(sqlpp::alias::a, t.alpha, t.beta);
auto a = select(m).from(t).as(sqlpp::alias::b).a;
auto m = multi_column(alias::a, t.alpha, t.beta);
auto a = select(m).from(t).as(alias::b).a;
static_assert(not sqlpp::is_value_t<decltype(a)>::value, "a multi_column is not a value");
}
@ -307,7 +317,7 @@ int main()
s = s.set_limit(30);
s = s.set_limit(3);
std::cerr << "------------------------\n";
s.serialize(std::cerr, db);
interpret(s, printer).flush();
std::cerr << "------------------------\n";
using T = decltype(s);
static_assert(sqlpp::is_regular<T>::value, "type requirement");
@ -316,18 +326,18 @@ int main()
// Test that select can be called with zero columns if it is used with dynamic columns.
{
auto s = dynamic_select(db).dynamic_columns().add_column(t.alpha);
s.serialize(std::cerr, db); std::cerr << "\n";
interpret(s, printer).flush();
}
// Test that verbatim_table compiles
{
auto s = select(t.alpha).from(sqlpp::verbatim_table("my_unknown_table"));
s.serialize(std::cerr, db); std::cerr << "\n";
interpret(s, printer).flush();
}
static_assert(sqlpp::is_select_flag_t<decltype(sqlpp::all)>::value, "sqlpp::all has to be a select_flag");
using T = sqlpp::detail::wrap_operand<int>::type;
using T = sqlpp::vendor::wrap_operand<int>::type;
static_assert(sqlpp::is_regular<T>::value, "type requirement");
static_assert(T::_is_expression, "T has to be an expression");
static_assert(std::is_same<typename T::_value_type::_is_numeric, std::true_type>::value, "T has to be a numeric");
@ -339,29 +349,28 @@ int main()
auto y = t.gamma and true and t.gamma;
!t.gamma;
t.beta < "kaesekuchen";
(t.beta + "hallenhalma").serialize(std::cerr, db);
concat(t.beta, "hallenhalma").serialize(std::cerr, db);
interpret(t.beta + "hallenhalma", printer).flush();
static_assert(sqlpp::must_not_insert_t<decltype(t.alpha)>::value, "alpha must not be inserted");
t.alpha.serialize(std::cerr, db);
interpret(t.alpha, printer).flush();
std::cerr << "\n" << sizeof(TabSample) << std::endl;
static_assert(std::is_same<typename decltype(t.alpha)::_value_type::_is_named_expression, std::true_type>::value, "alpha should be a named expression");
static_assert(sqlpp::is_named_expression_t<decltype(t.alpha)>::value, "alpha should be a named expression");
static_assert(sqlpp::is_named_expression_t<decltype(t.alpha.as(sqlpp::alias::a))>::value, "an alias of alpha should be a named expression");
static_assert(sqlpp::is_alias_t<decltype(t.alpha.as(sqlpp::alias::a))>::value, "an alias of alpha should be an alias");
static_assert(sqlpp::is_named_expression_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 z = select(t.alpha) == 7;
auto l = t.as(sqlpp::alias::left);
auto r = select(t.gamma.as(sqlpp::alias::a)).from(t).where(t.gamma == true).as(sqlpp::alias::right);
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");
select(sqlpp::distinct, sqlpp::straight_join, l.alpha, l.beta, select(r.a).from(r))
interpret(select(sqlpp::distinct, sqlpp::straight_join, l.alpha, l.beta, select(r.a).from(r))
.from(l, r)
.where(t.beta == "hello world" and select(t.gamma).from(t))// .as(sqlpp::alias::right))
.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(sqlpp::alias::a)
.serialize(std::cerr, db);
.as(alias::a)
, printer).flush();
return 0;
}

View File

@ -30,6 +30,7 @@
#include "is_regular.h"
DbMock db;
DbMock::_context_t printer(std::cerr);
int main()
{
@ -54,12 +55,12 @@ int main()
static_assert(sqlpp::is_regular<T>::value, "type requirement");
}
update(t).serialize(std::cerr, db); std::cerr << "\n";
update(t).set(t.gamma = false).serialize(std::cerr, db); std::cerr << "\n";
update(t).set(t.gamma = false).where(t.beta != "transparent").serialize(std::cerr, db); std::cerr << "\n";
interpret(update(t), printer).flush();
interpret(update(t).set(t.gamma = false), printer).flush();
interpret(update(t).set(t.gamma = false).where(t.beta != "transparent"), printer).flush();
auto u = dynamic_update(db, t).dynamic_set(t.gamma = false).dynamic_where();
u = u.add_set(t.gamma = false);
u.serialize(std::cerr, db); std::cerr << "\n";
interpret(u, printer).flush();
return 0;
}