Removed _name_t from and added alias operators to result field.

A result field really is just a value, if you insist on using it as a
select column, give it a name via an alias.
This commit is contained in:
rbock
2014-07-30 22:03:11 +02:00
parent 828106acbd
commit 7c45e8b83f
2 changed files with 5 additions and 5 deletions

View File

@@ -28,6 +28,7 @@
#define SQLPP_RESULT_FIELD_METHODS_H
#include <utility>
#include <sqlpp11/basic_expression_operators.h>
namespace sqlpp
{
@@ -69,7 +70,8 @@ namespace sqlpp
};
template<typename Field>
struct result_field_methods_t: public result_field_methods_base_t<Field>
struct result_field_methods_t: public result_field_methods_base_t<Field>,
public alias_operators<Field>
{
using _base_t = result_field_methods_base_t<Field>;
using _field_spec_t = typename _base_t::_field_spec_t;
@@ -89,8 +91,6 @@ namespace sqlpp
using _can_be_null = column_spec_can_be_null_t<_field_spec_t>;
};
using _name_t = typename _field_spec_t::_name_t;
};
}

View File

@@ -50,13 +50,13 @@ int main()
static_assert(std::is_member_function_pointer<decltype(&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, "row.alpha can be null");
static_assert(sqlpp::is_result_field_t<T>::value, "result_fields are not wrapped");
bool x = sqlpp::rhs_is_null(t.alpha == row.alpha);
bool y = sqlpp::rhs_is_trivial(t.alpha == row.alpha);
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;