Allow result_t to have a size() function if DbResult has a size() function.

size() must be const, but can be arbitrary type.
size() may be wrong after first next has been called
This commit is contained in:
Aaron Bishop
2017-10-21 16:09:30 -04:00
parent f6cb213e55
commit fb84f9b4a9
3 changed files with 38 additions and 2 deletions

View File

@@ -65,9 +65,11 @@ namespace
static_assert(not sqlpp::can_be_null_t<decltype(x.s)>::value, "constant non-null value can not be null");
}
{
const auto& x = db(select(bar.alpha, foo.delta, bar.gamma, seven)
auto&& result = db(select(bar.alpha, foo.delta, bar.gamma, seven)
.from(bar.join(foo).on(foo.omega > bar.alpha))
.unconditionally()).front();
.unconditionally());
const auto& x = result.front();
static_assert(std::is_same<decltype(result.size()), size_t>::value, "db doesn't have size_t result_t.size() ");
static_assert(sqlpp::can_be_null_t<decltype(x.alpha)>::value, "nullable value can always be null");
static_assert(not sqlpp::can_be_null_t<decltype(x.gamma)>::value, "left side of (inner) join cannot be null");
static_assert(not sqlpp::can_be_null_t<decltype(x.delta)>::value, "right side of (inner) join cannot be null");