mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-02-17 19:58:42 -06:00
InterpretTest compiles again
This commit is contained in:
@@ -50,7 +50,7 @@ namespace sqlpp
|
||||
{
|
||||
using _provided_tables = detail::type_set<>;
|
||||
using _required_tables = ::sqlpp::detail::type_set<>;
|
||||
static_assert(not is_expression_t<T>::value, "value() is to be called with non-sql-type like int, or string");
|
||||
static_assert(is_wrapped_value_t<vendor::wrap_operand_t<T>>::value, "value() is to be called with non-sql-type like int, or string");
|
||||
return { t };
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace sqlpp
|
||||
template<typename Container>
|
||||
auto value_list(Container c) -> value_list_t<Container>
|
||||
{
|
||||
static_assert(not is_expression_t<typename Container::value_type>::value, "value_list() is to be called with a container of non-sql-type like std::vector<int>, or std::list(string)");
|
||||
static_assert(is_wrapped_value_t<vendor::wrap_operand_t<typename Container::value_type>>::value, "value_list() is to be called with a container of non-sql-type like std::vector<int>, or std::list(string)");
|
||||
return { c };
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace sqlpp
|
||||
// integral value type
|
||||
struct integral
|
||||
{
|
||||
using _traits = make_traits<integral, ::sqlpp::tag::expression>;
|
||||
using _tag = ::sqlpp::tag::integral;
|
||||
using _cpp_value_type = int64_t;
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace sqlpp
|
||||
static_assert(not is_join_t<Rhs>::value, "rhs argument for join must not be a join");
|
||||
static_assert(vendor::is_noop<On>::value or is_on_t<On>::value, "invalid on expression in join().on()");
|
||||
|
||||
static_assert(::sqlpp::detail::is_disjunct_from<typename Lhs::_provided_tables, typename Rhs::_provided_tables>::value, "joined tables must not be identical");
|
||||
static_assert(::sqlpp::detail::is_disjunct_from<provided_tables_of<Lhs>, provided_tables_of<Rhs>>::value, "joined tables must not be identical");
|
||||
|
||||
static_assert(_recursive_traits::_required_tables::size::value == 0, "joined tables must not depend on other tables");
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace sqlpp
|
||||
|
||||
template<typename NamedExpr>
|
||||
auto parameter(const NamedExpr&)
|
||||
-> parameter_t<typename NamedExpr::_value_type, NamedExpr>
|
||||
-> parameter_t<value_type_of<NamedExpr>, NamedExpr>
|
||||
{
|
||||
static_assert(is_named_expression_t<NamedExpr>::value, "not a named expression");
|
||||
return {};
|
||||
@@ -82,7 +82,7 @@ namespace sqlpp
|
||||
|
||||
template<typename ValueType, typename AliasProvider>
|
||||
auto parameter(const ValueType&, const AliasProvider&)
|
||||
-> parameter_t<ValueType, AliasProvider>
|
||||
-> parameter_t<vendor::wrap_operand_t<ValueType>, AliasProvider>
|
||||
{
|
||||
static_assert(is_expression_t<ValueType>::value, "first argument is not a value type");
|
||||
static_assert(is_alias_provider_t<AliasProvider>::value, "second argument is not an alias provider");
|
||||
|
||||
@@ -35,10 +35,8 @@
|
||||
|
||||
namespace sqlpp
|
||||
{
|
||||
struct table_alias_base_t {};
|
||||
|
||||
template<typename AliasProvider, typename Table, typename... ColumnSpec>
|
||||
struct table_alias_t: public table_alias_base_t, public ColumnSpec::_name_t::template _member_t<column_t<AliasProvider, ColumnSpec>>...
|
||||
struct table_alias_t: public ColumnSpec::_name_t::template _member_t<column_t<AliasProvider, ColumnSpec>>...
|
||||
{
|
||||
//FIXME: Need to add join functionality
|
||||
using _traits = make_traits<value_type_of<Table>, tag::table, tag::alias, tag::named_expression_if<is_expression_t<Table>>>;
|
||||
@@ -65,10 +63,10 @@ namespace sqlpp
|
||||
|
||||
namespace vendor
|
||||
{
|
||||
template<typename Context, typename X>
|
||||
struct serializer_t<Context, X, typename std::enable_if<std::is_base_of<table_alias_base_t, X>::value, void>::type>
|
||||
template<typename Context, typename AliasProvider, typename Table, typename... ColumnSpec>
|
||||
struct serializer_t<Context, table_alias_t<AliasProvider, Table, ColumnSpec...>>
|
||||
{
|
||||
using T = X;
|
||||
using T = table_alias_t<AliasProvider, Table, ColumnSpec...>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
|
||||
@@ -42,6 +42,8 @@ namespace sqlpp
|
||||
using _traits = make_traits<value_type_of<Operand>, tag::expression>;
|
||||
using _recursive_traits = make_recursive_traits<Operand>;
|
||||
|
||||
using _operand_t = Operand;
|
||||
|
||||
tvin_t(Operand operand):
|
||||
_value(operand)
|
||||
{}
|
||||
|
||||
@@ -88,6 +88,7 @@ namespace sqlpp
|
||||
detail::is_element_of<tag::integral, typename T::_traits::_tags>::value,
|
||||
detail::is_element_of<tag::floating_point, typename T::_traits::_tags>::value>;
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(text);
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(wrapped_value);
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(expression);
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(named_expression);
|
||||
namespace tag
|
||||
|
||||
2
include/sqlpp11/vendor/expression.h
vendored
2
include/sqlpp11/vendor/expression.h
vendored
@@ -203,7 +203,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template<typename O, typename Rhs>
|
||||
struct unary_expression_t: public O::_value_type::template expression_operators<unary_expression_t<O, Rhs>>,
|
||||
struct unary_expression_t: public value_type_of<O>::template expression_operators<unary_expression_t<O, Rhs>>,
|
||||
public alias_operators<unary_expression_t<O, Rhs>>
|
||||
{
|
||||
using _traits = make_traits<value_type_of<O>, sqlpp::tag::expression>;
|
||||
|
||||
10
include/sqlpp11/vendor/insert_value_list.h
vendored
10
include/sqlpp11/vendor/insert_value_list.h
vendored
@@ -282,14 +282,14 @@ namespace sqlpp
|
||||
{
|
||||
using _data_t = column_list_data_t<Columns...>;
|
||||
|
||||
_impl_t<Policies> column_list;
|
||||
_impl_t<Policies>& operator()() { return column_list; }
|
||||
const _impl_t<Policies>& operator()() const { return column_list; }
|
||||
_impl_t<Policies> values;
|
||||
_impl_t<Policies>& operator()() { return values; }
|
||||
const _impl_t<Policies>& operator()() const { return values; }
|
||||
|
||||
template<typename T>
|
||||
static auto _get_member(T t) -> decltype(t.column_list)
|
||||
static auto _get_member(T t) -> decltype(t.values)
|
||||
{
|
||||
return t.column_list;
|
||||
return t.values;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
4
include/sqlpp11/vendor/limit.h
vendored
4
include/sqlpp11/vendor/limit.h
vendored
@@ -243,9 +243,9 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template<typename Context, typename Limit>
|
||||
struct serializer_t<Context, limit_t<Limit>>
|
||||
struct serializer_t<Context, limit_data_t<Limit>>
|
||||
{
|
||||
using T = limit_t<Limit>;
|
||||
using T = limit_data_t<Limit>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
|
||||
4
include/sqlpp11/vendor/select_pseudo_table.h
vendored
4
include/sqlpp11/vendor/select_pseudo_table.h
vendored
@@ -55,8 +55,8 @@ namespace sqlpp
|
||||
Select,
|
||||
NamedExpr...>, select_column_spec_t<NamedExpr>...>
|
||||
{
|
||||
using _value_type = no_value_t;
|
||||
using _is_pseudo_table = std::true_type;
|
||||
using _traits = make_traits<no_value_t, tag::table, tag::pseudo_table>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
select_pseudo_table_t(Select select):
|
||||
_select(select)
|
||||
|
||||
8
include/sqlpp11/vendor/wrap_operand.h
vendored
8
include/sqlpp11/vendor/wrap_operand.h
vendored
@@ -45,7 +45,7 @@ namespace sqlpp
|
||||
{
|
||||
struct boolean_operand
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::boolean, ::sqlpp::tag::expression>;
|
||||
using _traits = make_traits<::sqlpp::detail::boolean, ::sqlpp::tag::expression, ::sqlpp::tag::wrapped_value>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
using _value_t = bool;
|
||||
@@ -83,7 +83,7 @@ namespace sqlpp
|
||||
|
||||
struct integral_operand
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::integral, ::sqlpp::tag::expression>;
|
||||
using _traits = make_traits<::sqlpp::detail::integral, ::sqlpp::tag::expression, ::sqlpp::tag::wrapped_value>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
using _value_t = int64_t;
|
||||
@@ -122,7 +122,7 @@ namespace sqlpp
|
||||
|
||||
struct floating_point_operand
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::floating_point, ::sqlpp::tag::expression>;
|
||||
using _traits = make_traits<::sqlpp::detail::floating_point, ::sqlpp::tag::expression, ::sqlpp::tag::wrapped_value>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
using _value_t = double;
|
||||
@@ -160,7 +160,7 @@ namespace sqlpp
|
||||
|
||||
struct text_operand
|
||||
{
|
||||
using _traits = make_traits<::sqlpp::detail::text, ::sqlpp::tag::expression>;
|
||||
using _traits = make_traits<::sqlpp::detail::text, ::sqlpp::tag::expression, ::sqlpp::tag::wrapped_value>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
using _value_t = std::string;
|
||||
|
||||
@@ -6,10 +6,10 @@ macro (build_and_run arg)
|
||||
add_test(${arg} ${arg})
|
||||
endmacro ()
|
||||
|
||||
#build_and_run(InterpretTest)
|
||||
build_and_run(InterpretTest)
|
||||
#build_and_run(InsertTest)
|
||||
#build_and_run(RemoveTest)
|
||||
build_and_run(UpdateTest)
|
||||
#build_and_run(UpdateTest)
|
||||
#build_and_run(SelectTest)
|
||||
#build_and_run(SelectTypeTest)
|
||||
#build_and_run(FunctionTest)
|
||||
|
||||
@@ -67,8 +67,8 @@ int main()
|
||||
serialize(insert_into(t).set(t.beta = "kirschauflauf"), printer).str();
|
||||
serialize(insert_into(t).columns(t.beta), printer).str();
|
||||
auto multi_insert = insert_into(t).columns(t.beta, t.delta);
|
||||
multi_insert.column_list.add(t.beta = "cheesecake", t.delta = 1);
|
||||
multi_insert.column_list.add(t.beta = sqlpp::default_value, t.delta = sqlpp::default_value);
|
||||
multi_insert.values.add(t.beta = "cheesecake", t.delta = 1);
|
||||
multi_insert.values.add(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");
|
||||
serialize(i, printer).str();
|
||||
|
||||
@@ -46,12 +46,12 @@ int main()
|
||||
serialize(insert_into(t).columns(t.beta, t.gamma), printer).str();
|
||||
{
|
||||
auto i = insert_into(t).columns(t.gamma, t.beta);
|
||||
i.add_values(t.gamma = true, t.beta = "cheesecake");
|
||||
i.values.add(t.gamma = true, t.beta = "cheesecake");
|
||||
serialize(i, printer).str();
|
||||
i.add_values(t.gamma = false, t.beta = sqlpp::tvin("coffee"));
|
||||
i.add_values(t.gamma = false, t.beta = sqlpp::tvin(std::string()));
|
||||
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.add_values(t.gamma = sqlpp::default_value, t.beta = sqlpp::null);
|
||||
i.values.add(t.gamma = sqlpp::default_value, t.beta = sqlpp::null);
|
||||
serialize(i, printer).str();
|
||||
}
|
||||
|
||||
@@ -134,22 +134,22 @@ int main()
|
||||
// dynamic select
|
||||
{
|
||||
auto s = dynamic_select(db).dynamic_flags().dynamic_columns().from(t);
|
||||
s.add_column(t.beta);
|
||||
s.add_column(t.gamma);
|
||||
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.add_flag(sqlpp::distinct);
|
||||
s.add_column(t.beta);
|
||||
s.add_column(t.gamma);
|
||||
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.add_flag(sqlpp::all);
|
||||
s.add_column(t.beta);
|
||||
s.add_column(t.gamma);
|
||||
s.select_flags.add(sqlpp::all);
|
||||
s.selected_columns.add(t.beta);
|
||||
s.selected_columns.add(t.gamma);
|
||||
serialize(s, printer).str();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user