mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Function tests compile again
This commit is contained in:
parent
1d905e1db5
commit
5f4a88c7ce
@ -87,6 +87,7 @@ namespace sqlpp
|
||||
{
|
||||
static_assert(is_select_t<vendor::wrap_operand_t<T>>::value, "any() requires a select expression as argument");
|
||||
static_assert(is_expression_t<vendor::wrap_operand_t<T>>::value, "any() requires a single column select expression as argument");
|
||||
// FIXME: can we accept non-values like NULL here?
|
||||
return { t };
|
||||
}
|
||||
|
||||
|
@ -112,27 +112,27 @@ namespace sqlpp
|
||||
static_assert(is_noop_t<ColumnList>::value or sqlpp::is_select_column_list_t<ColumnList>::value, "column list of select is neither naught nor a valid column list");
|
||||
static_assert(is_noop_t<From>::value or sqlpp::is_from_t<From>::value, "from() part of select is neither naught nor a valid from()");
|
||||
|
||||
using _known_tables = detail::make_joined_set_t<typename _from_t::_table_set, typename _extra_tables_t::_table_set>;
|
||||
using _known_tables = detail::make_joined_set_t<provided_tables_of<_from_t>, provided_tables_of<_extra_tables_t>>; // FIXME, use provided_tables_of<THIS>;
|
||||
|
||||
template<typename Expression>
|
||||
using _no_unknown_tables = detail::is_subset_of<typename Expression::_table_set, _known_tables>;
|
||||
using _no_unknown_tables = detail::is_subset_of<required_tables_of<Expression>, _known_tables>;
|
||||
|
||||
using _required_tables =
|
||||
detail::make_joined_set_t<
|
||||
typename _flag_list_t::_table_set,
|
||||
typename _column_list_t::_table_set,
|
||||
typename _where_t::_table_set,
|
||||
typename _group_by_t::_table_set,
|
||||
typename _having_t::_table_set,
|
||||
typename _order_by_t::_table_set,
|
||||
typename _limit_t::_table_set,
|
||||
typename _offset_t::_table_set
|
||||
required_tables_of<_flag_list_t>,
|
||||
required_tables_of<_column_list_t>,
|
||||
required_tables_of<_where_t>,
|
||||
required_tables_of<_group_by_t>,
|
||||
required_tables_of<_having_t>,
|
||||
required_tables_of<_order_by_t>,
|
||||
required_tables_of<_limit_t>,
|
||||
required_tables_of<_offset_t>
|
||||
>;
|
||||
|
||||
// The tables not covered by the from.
|
||||
using _table_set = detail::make_difference_set_t<
|
||||
_required_tables,
|
||||
typename _from_t::_table_set // Hint: extra_tables_t is not used here because it is just a helper for dynamic .add_*() methods and should not change the structural integrity
|
||||
provided_tables_of<_from_t> // Hint: extra_tables_t is not used here because it is just a helper for dynamic .add_*() methods and should not change the structural integrity
|
||||
>;
|
||||
|
||||
// A select can be used as a pseudo table if
|
||||
@ -145,10 +145,12 @@ namespace sqlpp
|
||||
>::type;
|
||||
|
||||
using _value_type = typename std::conditional<
|
||||
is_select_column_list_t<_column_list_t>::value and is_subset_of<typename _column_list_t::_table_set, typename _from_t::_table_set>::value,
|
||||
typename ColumnList::_value_type,
|
||||
is_select_column_list_t<_column_list_t>::value and is_subset_of<required_tables_of<_column_list_t>, provided_tables_of<_from_t>>::value,
|
||||
value_type_of<_column_list_t>,
|
||||
no_value_t // If something is selected that requires a table, then we require a from for this to be a value
|
||||
>::type;
|
||||
|
||||
using _traits = make_traits<_value_type>;
|
||||
};
|
||||
}
|
||||
|
||||
@ -160,6 +162,9 @@ namespace sqlpp
|
||||
public detail::select_policies_t<Db, Policies...>::_value_type::template expression_operators<select_t<Db, Policies...>>,
|
||||
public detail::select_policies_t<Db, Policies...>::_methods_t
|
||||
{
|
||||
using _traits = make_traits<value_type_of<detail::select_policies_t<Db, Policies...>>, ::sqlpp::tag::select>;
|
||||
using _recursive_traits = make_recursive_traits<>; // FIXME
|
||||
|
||||
using _policies_t = typename detail::select_policies_t<Db, Policies...>;
|
||||
using _database_t = typename _policies_t::_database_t;
|
||||
using _flag_list_t = typename _policies_t::_flag_list_t;
|
||||
|
@ -114,6 +114,7 @@ namespace sqlpp
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(select_flag_list);
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(select_column_list);
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(from);
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(extra_tables);
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(on);
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(dynamic);
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(where);
|
||||
@ -142,17 +143,6 @@ namespace sqlpp
|
||||
template<typename T, template<typename> class IsTag>
|
||||
using copy_type_trait = typename std::conditional<IsTag<T>::value, std::true_type, std::false_type>::type;
|
||||
|
||||
template<typename ValueType, typename... Tags>
|
||||
struct make_traits
|
||||
{
|
||||
using _value_type = ValueType;
|
||||
using _tags = detail::make_type_set_t<typename ValueType::_tag, Tags...>;
|
||||
};
|
||||
template<typename... Arguments>
|
||||
struct make_recursive_traits
|
||||
{
|
||||
};
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template<typename T>
|
||||
@ -181,6 +171,20 @@ namespace sqlpp
|
||||
|
||||
template<typename T>
|
||||
using provided_tables_of = typename detail::provided_table_of_impl<T>::type;
|
||||
|
||||
template<typename ValueType, typename... Tags>
|
||||
struct make_traits
|
||||
{
|
||||
using _value_type = ValueType;
|
||||
using _tags = detail::make_type_set_t<typename ValueType::_tag, Tags...>;
|
||||
};
|
||||
template<typename... Arguments>
|
||||
struct make_recursive_traits
|
||||
{
|
||||
using _required_tables = detail::make_joined_set_t<required_tables_of<Arguments>...>;
|
||||
using _provided_tables = detail::make_joined_set_t<provided_tables_of<Arguments>...>;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
4
include/sqlpp11/vendor/assignment.h
vendored
4
include/sqlpp11/vendor/assignment.h
vendored
@ -65,7 +65,7 @@ namespace sqlpp
|
||||
template<typename Lhs, typename Rhs>
|
||||
struct assignment_t
|
||||
{
|
||||
using _traits = make_traits<no_value_t, tag::assignment>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::assignment>;
|
||||
using _recursive_traits = make_recursive_traits<Lhs, Rhs>;
|
||||
|
||||
using _column_t = Lhs;
|
||||
@ -115,7 +115,7 @@ namespace sqlpp
|
||||
template<typename Lhs, typename Rhs>
|
||||
struct assignment_t<Lhs, tvin_t<Rhs>>
|
||||
{
|
||||
using _traits = make_traits<no_value_t, tag::assignment>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::assignment>;
|
||||
using _recursive_traits = make_recursive_traits<Lhs, Rhs>;
|
||||
|
||||
using _column_t = Lhs;
|
||||
|
6
include/sqlpp11/vendor/expression.h
vendored
6
include/sqlpp11/vendor/expression.h
vendored
@ -40,7 +40,7 @@ namespace sqlpp
|
||||
namespace vendor
|
||||
{
|
||||
template<typename Lhs, typename Rhs>
|
||||
struct binary_expression_t<Lhs, tag::equal_to, Rhs>: public ::sqlpp::detail::boolean::template expression_operators<equal_to_t<Lhs, Rhs>>
|
||||
struct binary_expression_t<Lhs, op::equal_to, Rhs>: public ::sqlpp::detail::boolean::template expression_operators<equal_to_t<Lhs, Rhs>>
|
||||
{
|
||||
using _traits = make_traits<boolean, sqlpp::tag::expression>;
|
||||
using _recursive_traits = make_recursive_traits<Lhs, Rhs>;
|
||||
@ -84,7 +84,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
struct binary_expression_t<Lhs, tag::not_equal_to, Rhs>: public ::sqlpp::detail::boolean::template expression_operators<not_equal_to_t<Lhs, Rhs>>
|
||||
struct binary_expression_t<Lhs, op::not_equal_to, Rhs>: public ::sqlpp::detail::boolean::template expression_operators<not_equal_to_t<Lhs, Rhs>>
|
||||
{
|
||||
using _traits = make_traits<boolean, sqlpp::tag::expression>;
|
||||
using _recursive_traits = make_recursive_traits<Lhs, Rhs>;
|
||||
@ -128,7 +128,7 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
template<typename Rhs>
|
||||
struct unary_expression_t<tag::logical_not, Rhs>: public ::sqlpp::detail::boolean::template expression_operators<logical_not_t<Rhs>>
|
||||
struct unary_expression_t<op::logical_not, Rhs>: public ::sqlpp::detail::boolean::template expression_operators<logical_not_t<Rhs>>
|
||||
{
|
||||
using _traits = make_traits<boolean, sqlpp::tag::expression>;
|
||||
using _recursive_traits = make_recursive_traits<Rhs>;
|
||||
|
34
include/sqlpp11/vendor/expression_fwd.h
vendored
34
include/sqlpp11/vendor/expression_fwd.h
vendored
@ -31,7 +31,7 @@ namespace sqlpp
|
||||
{
|
||||
namespace vendor
|
||||
{
|
||||
namespace tag
|
||||
namespace op
|
||||
{
|
||||
struct less
|
||||
{
|
||||
@ -139,52 +139,52 @@ namespace sqlpp
|
||||
struct unary_expression_t;
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
using less_than_t = binary_expression_t<Lhs, tag::less, Rhs>;
|
||||
using less_than_t = binary_expression_t<Lhs, op::less, Rhs>;
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
using less_equal_t = binary_expression_t<Lhs, tag::less_equal, Rhs>;
|
||||
using less_equal_t = binary_expression_t<Lhs, op::less_equal, Rhs>;
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
using equal_to_t = binary_expression_t<Lhs, tag::equal_to, Rhs>;
|
||||
using equal_to_t = binary_expression_t<Lhs, op::equal_to, Rhs>;
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
using not_equal_to_t = binary_expression_t<Lhs, tag::not_equal_to, Rhs>;
|
||||
using not_equal_to_t = binary_expression_t<Lhs, op::not_equal_to, Rhs>;
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
using greater_than_t = binary_expression_t<Lhs, tag::greater, Rhs>;
|
||||
using greater_than_t = binary_expression_t<Lhs, op::greater, Rhs>;
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
using greater_equal_t = binary_expression_t<Lhs, tag::greater_equal, Rhs>;
|
||||
using greater_equal_t = binary_expression_t<Lhs, op::greater_equal, Rhs>;
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
using logical_and_t = binary_expression_t<Lhs, tag::logical_and, Rhs>;
|
||||
using logical_and_t = binary_expression_t<Lhs, op::logical_and, Rhs>;
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
using logical_or_t = binary_expression_t<Lhs, tag::logical_or, Rhs>;
|
||||
using logical_or_t = binary_expression_t<Lhs, op::logical_or, Rhs>;
|
||||
|
||||
template<typename Lhs, typename ValueType, typename Rhs>
|
||||
using plus_t = binary_expression_t<Lhs, tag::plus<ValueType>, Rhs>;
|
||||
using plus_t = binary_expression_t<Lhs, op::plus<ValueType>, Rhs>;
|
||||
|
||||
template<typename Lhs, typename ValueType, typename Rhs>
|
||||
using minus_t = binary_expression_t<Lhs, tag::minus<ValueType>, Rhs>;
|
||||
using minus_t = binary_expression_t<Lhs, op::minus<ValueType>, Rhs>;
|
||||
|
||||
template<typename Lhs, typename ValueType, typename Rhs>
|
||||
using multiplies_t = binary_expression_t<Lhs, tag::multiplies<ValueType>, Rhs>;
|
||||
using multiplies_t = binary_expression_t<Lhs, op::multiplies<ValueType>, Rhs>;
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
using divides_t = binary_expression_t<Lhs, tag::divides, Rhs>;
|
||||
using divides_t = binary_expression_t<Lhs, op::divides, Rhs>;
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
using modulus_t = binary_expression_t<Lhs, tag::modulus, Rhs>;
|
||||
using modulus_t = binary_expression_t<Lhs, op::modulus, Rhs>;
|
||||
|
||||
template<typename Rhs>
|
||||
using logical_not_t = unary_expression_t<tag::logical_not, Rhs>;
|
||||
using logical_not_t = unary_expression_t<op::logical_not, Rhs>;
|
||||
|
||||
template<typename ValueType, typename Rhs>
|
||||
using unary_plus_t = unary_expression_t<tag::unary_plus<ValueType>, Rhs>;
|
||||
using unary_plus_t = unary_expression_t<op::unary_plus<ValueType>, Rhs>;
|
||||
|
||||
template<typename ValueType, typename Rhs>
|
||||
using unary_minus_t = unary_expression_t<tag::unary_minus<ValueType>, Rhs>;
|
||||
using unary_minus_t = unary_expression_t<op::unary_minus<ValueType>, Rhs>;
|
||||
|
||||
}
|
||||
}
|
||||
|
4
include/sqlpp11/vendor/extra_tables.h
vendored
4
include/sqlpp11/vendor/extra_tables.h
vendored
@ -39,7 +39,7 @@ namespace sqlpp
|
||||
template<typename... Tables>
|
||||
struct extra_tables_t
|
||||
{
|
||||
using _traits = make_traits<no_value_t, tag::extra_tables>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::extra_tables>;
|
||||
using _recursive_traits = make_recursive_traits<Tables...>;
|
||||
|
||||
// FIXME: extra_tables must not require tables!
|
||||
@ -65,7 +65,7 @@ namespace sqlpp
|
||||
|
||||
struct no_extra_tables_t
|
||||
{
|
||||
using _traits = make_traits<no_value_t, tag::noop>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::noop>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
template<typename Policies>
|
||||
|
2
include/sqlpp11/vendor/field.h
vendored
2
include/sqlpp11/vendor/field.h
vendored
@ -52,7 +52,7 @@ namespace sqlpp
|
||||
struct make_field_t_impl
|
||||
{
|
||||
using type = field_t<typename NamedExpr::_name_t,
|
||||
value_of<NamedExpr>,
|
||||
value_type_of<NamedExpr>,
|
||||
trivial_value_is_null_t<NamedExpr>::value>;
|
||||
};
|
||||
|
||||
|
4
include/sqlpp11/vendor/from.h
vendored
4
include/sqlpp11/vendor/from.h
vendored
@ -41,7 +41,7 @@ namespace sqlpp
|
||||
template<typename Database, typename... Tables>
|
||||
struct from_t
|
||||
{
|
||||
using _traits = make_traits<no_value_t, tag::from>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::from>;
|
||||
using _recursive_traits = make_recursive_traits<Tables...>;
|
||||
|
||||
using _is_dynamic = typename std::conditional<std::is_same<Database, void>::value, std::false_type, std::true_type>::type;
|
||||
@ -97,7 +97,7 @@ namespace sqlpp
|
||||
|
||||
struct no_from_t
|
||||
{
|
||||
using _traits = make_traits<no_value_t, tag::noop>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::noop>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
template<typename Policies>
|
||||
|
6
include/sqlpp11/vendor/group_by.h
vendored
6
include/sqlpp11/vendor/group_by.h
vendored
@ -43,7 +43,7 @@ namespace sqlpp
|
||||
template<typename Database, typename... Expressions>
|
||||
struct group_by_t
|
||||
{
|
||||
using _traits = make_traits<no_value_t, tag::group_by>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::group_by>;
|
||||
using _recursive_traits = make_recursive_traits<Expressions...>;
|
||||
|
||||
using _is_dynamic = typename std::conditional<std::is_same<Database, void>::value, std::false_type, std::true_type>::type;
|
||||
@ -97,13 +97,13 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
const group_by_t& _group_by() const { return *this; }
|
||||
std::tuple<Expression...> _expressions;
|
||||
std::tuple<Expressions...> _expressions;
|
||||
vendor::interpretable_list_t<Database> _dynamic_expressions;
|
||||
};
|
||||
|
||||
struct no_group_by_t
|
||||
{
|
||||
using _traits = make_traits<no_value_t, tag::noop>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::noop>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
template<typename Policies>
|
||||
|
4
include/sqlpp11/vendor/having.h
vendored
4
include/sqlpp11/vendor/having.h
vendored
@ -42,7 +42,7 @@ namespace sqlpp
|
||||
template<typename Database, typename... Expressions>
|
||||
struct having_t
|
||||
{
|
||||
using _traits = make_traits<no_value_t, tag::having>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::having>;
|
||||
using _recursive_traits = make_recursive_traits<Expressions...>;
|
||||
|
||||
using _is_dynamic = typename std::conditional<std::is_same<Database, void>::value, std::false_type, std::true_type>::type;
|
||||
@ -98,7 +98,7 @@ namespace sqlpp
|
||||
|
||||
struct no_having_t
|
||||
{
|
||||
using _traits = make_traits<no_value_t, tag::noop>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::noop>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
template<typename Policies>
|
||||
|
18
include/sqlpp11/vendor/limit.h
vendored
18
include/sqlpp11/vendor/limit.h
vendored
@ -39,11 +39,10 @@ namespace sqlpp
|
||||
template<typename Limit>
|
||||
struct limit_t
|
||||
{
|
||||
using _is_limit = std::true_type;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::limit>;
|
||||
using _recursive_traits = make_recursive_traits<Limit>;
|
||||
|
||||
static_assert(is_integral_t<Limit>::value, "limit requires an integral value or integral parameter");
|
||||
// FIXME: Is this really always empty?
|
||||
using _provided_tables = detail::type_set<>;
|
||||
using _required_tables = ::sqlpp::detail::type_set<>;
|
||||
|
||||
limit_t(Limit value):
|
||||
_value(value)
|
||||
@ -66,10 +65,8 @@ namespace sqlpp
|
||||
template<typename Database>
|
||||
struct dynamic_limit_t
|
||||
{
|
||||
using _is_limit = std::true_type;
|
||||
using _is_dynamic = std::true_type;
|
||||
using _provided_tables = detail::type_set<>;
|
||||
using _required_tables = ::sqlpp::detail::type_set<>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::limit>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
dynamic_limit_t():
|
||||
_value(noop())
|
||||
@ -108,9 +105,8 @@ namespace sqlpp
|
||||
|
||||
struct no_limit_t
|
||||
{
|
||||
using _is_noop = std::true_type;
|
||||
using _provided_tables = detail::type_set<>;
|
||||
using _required_tables = ::sqlpp::detail::type_set<>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::noop>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
template<typename Policies>
|
||||
struct _methods_t
|
||||
|
17
include/sqlpp11/vendor/offset.h
vendored
17
include/sqlpp11/vendor/offset.h
vendored
@ -39,9 +39,9 @@ namespace sqlpp
|
||||
template<typename Offset>
|
||||
struct offset_t
|
||||
{
|
||||
using _is_offset = std::true_type;
|
||||
using _provided_tables = detail::type_set<>;
|
||||
using _required_tables = ::sqlpp::detail::type_set<>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::offset>;
|
||||
using _recursive_traits = make_recursive_traits<Offset>;
|
||||
|
||||
static_assert(is_integral_t<Offset>::value, "offset requires an integral value or integral parameter");
|
||||
|
||||
offset_t(Offset value):
|
||||
@ -65,10 +65,8 @@ namespace sqlpp
|
||||
template<typename Database>
|
||||
struct dynamic_offset_t
|
||||
{
|
||||
using _is_offset = std::true_type;
|
||||
using _is_dynamic = std::true_type;
|
||||
using _provided_tables = detail::type_set<>;
|
||||
using _required_tables = ::sqlpp::detail::type_set<>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::offset>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
dynamic_offset_t():
|
||||
_value(noop())
|
||||
@ -107,9 +105,8 @@ namespace sqlpp
|
||||
|
||||
struct no_offset_t
|
||||
{
|
||||
using _is_noop = std::true_type;
|
||||
using _provided_tables = detail::type_set<>;
|
||||
using _required_tables = ::sqlpp::detail::type_set<>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::noop>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
template<typename Policies>
|
||||
struct _methods_t
|
||||
|
16
include/sqlpp11/vendor/order_by.h
vendored
16
include/sqlpp11/vendor/order_by.h
vendored
@ -42,13 +42,10 @@ namespace sqlpp
|
||||
template<typename Database,typename... Expressions>
|
||||
struct order_by_t
|
||||
{
|
||||
using _is_order_by = std::true_type;
|
||||
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<Expressions...>;
|
||||
using _parameter_list_t = typename make_parameter_list_t<_parameter_tuple_t>::type;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::group_by>;
|
||||
using _recursive_traits = make_recursive_traits<Expressions...>;
|
||||
|
||||
using _provided_tables = detail::type_set<>;
|
||||
using _required_tables = typename ::sqlpp::detail::make_joined_set<typename Expressions::_required_tables...>::type;
|
||||
using _is_dynamic = typename std::conditional<std::is_same<Database, void>::value, std::false_type, std::true_type>::type;
|
||||
|
||||
static_assert(_is_dynamic::value or sizeof...(Expressions), "at least one sort-order expression required in order_by()");
|
||||
|
||||
@ -98,15 +95,14 @@ namespace sqlpp
|
||||
void _add_order_by_impl(Expression expression, const std::false_type&);
|
||||
};
|
||||
|
||||
_parameter_tuple_t _expressions;
|
||||
std::tuple<Expressions...> _expressions;
|
||||
vendor::interpretable_list_t<Database> _dynamic_expressions;
|
||||
};
|
||||
|
||||
struct no_order_by_t
|
||||
{
|
||||
using _is_noop = std::true_type;
|
||||
using _provided_tables = detail::type_set<>;
|
||||
using _required_tables = ::sqlpp::detail::type_set<>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::noop>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
template<typename Policies>
|
||||
struct _methods_t
|
||||
|
39
include/sqlpp11/vendor/select_column_list.h
vendored
39
include/sqlpp11/vendor/select_column_list.h
vendored
@ -47,14 +47,14 @@ namespace sqlpp
|
||||
template<typename... Rest>
|
||||
struct get_first_argument_if_unique
|
||||
{
|
||||
using _value_type = no_value_t;
|
||||
using _traits = make_traits<no_value_t, tag::select_column_list>;
|
||||
struct _name_t {};
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct get_first_argument_if_unique<T>
|
||||
{
|
||||
using _value_type = typename T::_value_type;
|
||||
using _traits = make_traits<value_type_of<T>, tag::select_column_list, tag::expression, tag::named_expression>;
|
||||
using _name_t = typename T::_name_t;
|
||||
};
|
||||
}
|
||||
@ -132,13 +132,13 @@ namespace sqlpp
|
||||
template<typename Database, typename... Columns>
|
||||
struct select_column_list_t
|
||||
{
|
||||
using _is_select_column_list = std::true_type;
|
||||
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<Columns...>;
|
||||
using size = std::tuple_size<_parameter_tuple_t>;
|
||||
// get_first_argument_if_unique is kind of ugly
|
||||
using _traits = typename ::sqlpp::detail::get_first_argument_if_unique<Columns...>::_traits;
|
||||
using _recursive_traits = make_recursive_traits<Columns...>;
|
||||
|
||||
using _provided_tables = detail::type_set<>;
|
||||
using _required_tables = sqlpp::detail::make_joined_set_t<typename Columns::_required_tables...>;
|
||||
using _name_t = typename ::sqlpp::detail::get_first_argument_if_unique<Columns...>::_name_t;
|
||||
|
||||
using _is_dynamic = typename std::conditional<std::is_same<Database, void>::value, std::false_type, std::true_type>::type;
|
||||
|
||||
static_assert(not ::sqlpp::detail::has_duplicates<Columns...>::value, "at least one duplicate argument detected");
|
||||
|
||||
@ -149,13 +149,7 @@ namespace sqlpp
|
||||
static_assert(not ::sqlpp::detail::has_duplicates<typename Columns::_name_t...>::value, "at least one duplicate name detected");
|
||||
|
||||
struct _column_type {};
|
||||
struct _value_type: ::sqlpp::detail::get_first_argument_if_unique<Columns...>::_value_type
|
||||
{
|
||||
using _is_expression = typename std::conditional<sizeof...(Columns) == 1, std::true_type, std::false_type>::type;
|
||||
using _is_named_expression = typename std::conditional<sizeof...(Columns) == 1, std::true_type, std::false_type>::type;
|
||||
using _is_alias = std::false_type;
|
||||
};
|
||||
using _name_t = typename ::sqlpp::detail::get_first_argument_if_unique<Columns...>::_name_t;
|
||||
|
||||
|
||||
template<typename Db>
|
||||
using _result_row_t = typename std::conditional<_is_dynamic::value,
|
||||
@ -186,7 +180,7 @@ namespace sqlpp
|
||||
|
||||
static constexpr size_t static_size()
|
||||
{
|
||||
return size::value;
|
||||
return sizeof...(Columns);
|
||||
}
|
||||
|
||||
template<typename Policies>
|
||||
@ -228,7 +222,7 @@ namespace sqlpp
|
||||
|
||||
|
||||
const select_column_list_t& _column_list() const { return *this; }
|
||||
_parameter_tuple_t _columns;
|
||||
std::tuple<Columns...> _columns;
|
||||
dynamic_select_column_list<Database> _dynamic_columns;
|
||||
};
|
||||
}
|
||||
@ -245,13 +239,12 @@ namespace sqlpp
|
||||
{
|
||||
struct no_select_column_list_t
|
||||
{
|
||||
using _is_noop = std::true_type;
|
||||
using _provided_tables = detail::type_set<>;
|
||||
using _required_tables = ::sqlpp::detail::type_set<>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::noop>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
template<typename Db>
|
||||
using _result_row_t = ::sqlpp::result_row_t<Db>;
|
||||
using _dynamic_names_t = typename dynamic_select_column_list<void>::_names_t;
|
||||
using _value_type = no_value_t;
|
||||
struct _name_t {};
|
||||
|
||||
template<typename T>
|
||||
@ -293,10 +286,10 @@ namespace sqlpp
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
// check for at least one expression
|
||||
static_assert(T::_is_dynamic::value or T::size::value, "at least one select expression required");
|
||||
static_assert(T::_is_dynamic::value or sizeof...(Columns), "at least one select expression required");
|
||||
|
||||
interpret_tuple(t._columns, ',', context);
|
||||
if (T::size::value and not t._dynamic_columns.empty())
|
||||
if (sizeof...(Columns) and not t._dynamic_columns.empty())
|
||||
context << ',';
|
||||
serialize(t._dynamic_columns, context);
|
||||
return context;
|
||||
|
15
include/sqlpp11/vendor/select_flag_list.h
vendored
15
include/sqlpp11/vendor/select_flag_list.h
vendored
@ -42,12 +42,10 @@ namespace sqlpp
|
||||
template<typename Database, typename... Flags>
|
||||
struct select_flag_list_t
|
||||
{
|
||||
using _is_select_flag_list = std::true_type;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::select_flag_list>;
|
||||
using _recursive_traits = make_recursive_traits<Flags...>;
|
||||
|
||||
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<Flags...>;
|
||||
using size = std::tuple_size<_parameter_tuple_t>;
|
||||
using _provided_tables = detail::type_set<>;
|
||||
using _required_tables = typename ::sqlpp::detail::make_joined_set<typename Flags::_required_tables...>::type;
|
||||
|
||||
static_assert(not ::sqlpp::detail::has_duplicates<Flags...>::value, "at least one duplicate argument detected in select flag list");
|
||||
|
||||
@ -96,15 +94,14 @@ namespace sqlpp
|
||||
};
|
||||
|
||||
const select_flag_list_t& _flag_list() const { return *this; }
|
||||
_parameter_tuple_t _flags;
|
||||
std::tuple<Flags...> _flags;
|
||||
vendor::interpretable_list_t<Database> _dynamic_flags;
|
||||
};
|
||||
|
||||
struct no_select_flag_list_t
|
||||
{
|
||||
using _is_noop = std::true_type;
|
||||
using _provided_tables = detail::type_set<>;
|
||||
using _required_tables = ::sqlpp::detail::type_set<>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::noop>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
template<typename Policies>
|
||||
struct _methods_t
|
||||
|
23
include/sqlpp11/vendor/where.h
vendored
23
include/sqlpp11/vendor/where.h
vendored
@ -42,19 +42,15 @@ namespace sqlpp
|
||||
template<typename Database, typename... Expressions>
|
||||
struct where_t
|
||||
{
|
||||
using _is_where = std::true_type;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::where>;
|
||||
using _recursive_traits = make_recursive_traits<Expressions...>;
|
||||
|
||||
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<Expressions...>;
|
||||
|
||||
static_assert(_is_dynamic::value or sizeof...(Expressions), "at least one expression argument required in where()");
|
||||
static_assert(sqlpp::detail::none_t<is_assignment_t<Expressions>::value...>::value, "at least one argument is an assignment in where()");
|
||||
static_assert(sqlpp::detail::all_t<is_expression_t<Expressions>::value...>::value, "at least one argument is not valid expression in where()");
|
||||
|
||||
using _parameter_list_t = typename make_parameter_list_t<_parameter_tuple_t>::type;
|
||||
|
||||
using _provided_tables = detail::type_set<>;
|
||||
using _required_tables = typename ::sqlpp::detail::make_joined_set<typename Expressions::_required_tables...>::type;
|
||||
|
||||
where_t(Expressions... expressions):
|
||||
_expressions(expressions...)
|
||||
{}
|
||||
@ -97,17 +93,15 @@ namespace sqlpp
|
||||
void _add_where_impl(Expression expression, const std::false_type&);
|
||||
};
|
||||
|
||||
_parameter_tuple_t _expressions;
|
||||
std::tuple<Expressions...> _expressions;
|
||||
vendor::interpretable_list_t<Database> _dynamic_expressions;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct where_t<void, bool>
|
||||
{
|
||||
using _is_where = std::true_type;
|
||||
using _is_dynamic = std::false_type;
|
||||
using _provided_tables = detail::type_set<>;
|
||||
using _required_tables = ::sqlpp::detail::type_set<>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::where>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
where_t(bool condition):
|
||||
_condition(condition)
|
||||
@ -129,9 +123,8 @@ namespace sqlpp
|
||||
|
||||
struct no_where_t
|
||||
{
|
||||
using _is_noop = std::true_type;
|
||||
using _provided_tables = detail::type_set<>;
|
||||
using _required_tables = ::sqlpp::detail::type_set<>;
|
||||
using _traits = make_traits<no_value_t, ::sqlpp::tag::where>;
|
||||
using _recursive_traits = make_recursive_traits<>;
|
||||
|
||||
template<typename Policies>
|
||||
struct _methods_t
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "Sample.h"
|
||||
#include "MockDb.h"
|
||||
#include <sqlpp11/alias_provider.h>
|
||||
//#include <sqlpp11/select.h>
|
||||
#include <sqlpp11/select.h>
|
||||
#include <sqlpp11/functions.h>
|
||||
#include <sqlpp11/connection.h>
|
||||
|
||||
@ -171,7 +171,6 @@ int main()
|
||||
// SUB_SELECT_FUNCTIONS
|
||||
// --------------------
|
||||
|
||||
#if 0
|
||||
// Test exists
|
||||
{
|
||||
using TI = decltype(exists(select(t.alpha).from(t)));
|
||||
@ -189,6 +188,9 @@ int main()
|
||||
|
||||
// Test any
|
||||
{
|
||||
using S = decltype(select(t.alpha).from(t));
|
||||
static_assert(sqlpp::is_numeric_t<S>::value, "type requirement");
|
||||
static_assert(sqlpp::is_numeric_t<S::_column_list_t>::value, "type requirement");
|
||||
|
||||
using TI = decltype(any(select(t.alpha).from(t)));
|
||||
using TT = decltype(any(select(t.beta).from(t)));
|
||||
@ -233,7 +235,6 @@ int main()
|
||||
static_assert(not sqlpp::is_floating_point_t<TT>::value, "type requirement");
|
||||
static_assert(sqlpp::is_text_t<TT>::value, "type requirement");
|
||||
}
|
||||
#endif
|
||||
|
||||
// NUMERIC FUNCTIONS
|
||||
// -----------------
|
||||
|
Loading…
Reference in New Issue
Block a user