mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Corrected inconsistency in select value_type
This commit is contained in:
parent
88fc0959b5
commit
61ed1d9f37
@ -69,6 +69,12 @@ namespace sqlpp
|
||||
{
|
||||
using _column_list_t = ColumnList;
|
||||
using _from_t = ColumnList;
|
||||
|
||||
using _value_type = typename std::conditional<
|
||||
sqlpp::is_from_t<From>::value,
|
||||
typename ColumnList::_value_type,
|
||||
no_value_t // If there is no from, the select is not complete (this logic is a bit simple, but better than nothing)
|
||||
>::type;
|
||||
template<typename Database>
|
||||
struct can_run_t
|
||||
{
|
||||
@ -87,7 +93,7 @@ namespace sqlpp
|
||||
// SELECT
|
||||
template<typename Database, typename... Policies>
|
||||
struct select_t: public vendor::policy_t<Policies>..., public vendor::crtp_wrapper_t<select_t<Database, Policies...>, Policies>...,
|
||||
public detail::select_helper_t<Policies...>::_column_list_t::_value_type::template operators<select_t<Database, Policies...>>
|
||||
public detail::select_helper_t<Policies...>::_value_type::template operators<select_t<Database, Policies...>>
|
||||
{
|
||||
template<typename Needle, typename Replacement>
|
||||
using _policy_update_t = select_t<Database, vendor::policy_update_t<Policies, Needle, Replacement>...>;
|
||||
@ -103,8 +109,7 @@ namespace sqlpp
|
||||
using _is_select = std::true_type;
|
||||
using _requires_braces = std::true_type;
|
||||
|
||||
// FIXME: introduce checks whether this select could really be used as a value
|
||||
using _value_type = typename _column_list_t::_value_type;
|
||||
using _value_type = typename detail::select_helper_t<Policies...>::_value_type;
|
||||
using _name_t = typename _column_list_t::_name_t;
|
||||
|
||||
select_t()
|
||||
|
1
include/sqlpp11/vendor/from.h
vendored
1
include/sqlpp11/vendor/from.h
vendored
@ -79,7 +79,6 @@ namespace sqlpp
|
||||
|
||||
struct no_from_t
|
||||
{
|
||||
using _is_from = std::true_type;
|
||||
const no_from_t& _from() const { return *this; }
|
||||
};
|
||||
|
||||
|
@ -159,8 +159,6 @@ int main()
|
||||
// Test a select of a single column without a from
|
||||
{
|
||||
using T = decltype(select(t.alpha)); // Hint: The current rule is pretty crude (a from is required), but certainly better than nothing
|
||||
#warning Need to reactivate these tests
|
||||
/*
|
||||
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");
|
||||
@ -172,7 +170,6 @@ int main()
|
||||
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
|
||||
@ -360,7 +357,7 @@ int main()
|
||||
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(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 z = select(t.alpha).from(t) == 7;
|
||||
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");
|
||||
|
Loading…
Reference in New Issue
Block a user