0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Allow non-zero start values for dynamic limit and offset

This commit is contained in:
Roland Bock 2013-11-18 07:32:09 +01:00
parent 8d12d23d67
commit 6f780a9542
3 changed files with 6 additions and 25 deletions

View File

@ -52,16 +52,6 @@ namespace sqlpp
using _is_limit = std::true_type; using _is_limit = std::true_type;
using _is_dynamic = std::true_type; using _is_dynamic = std::true_type;
dynamic_limit_t():
_limit(0)
{}
dynamic_limit_t(const dynamic_limit_t&) = default;
dynamic_limit_t(dynamic_limit_t&&) = default;
dynamic_limit_t& operator=(const dynamic_limit_t&) = default;
dynamic_limit_t& operator=(dynamic_limit_t&&) = default;
~dynamic_limit_t() = default;
void set(std::size_t limit) void set(std::size_t limit)
{ {
_limit = limit; _limit = limit;
@ -75,7 +65,7 @@ namespace sqlpp
os << " LIMIT " << _limit; os << " LIMIT " << _limit;
} }
std::size_t _limit = 0; std::size_t _limit;
}; };
} }

View File

@ -51,15 +51,6 @@ namespace sqlpp
using _is_offset = std::true_type; using _is_offset = std::true_type;
using _is_dynamic = std::true_type; using _is_dynamic = std::true_type;
dynamic_offset_t():
_offset(0)
{}
dynamic_offset_t(const dynamic_offset_t&) = default;
dynamic_offset_t(dynamic_offset_t&&) = default;
dynamic_offset_t& operator=(const dynamic_offset_t&) = default;
dynamic_offset_t& operator=(dynamic_offset_t&&) = default;
~dynamic_offset_t() = default;
void set(std::size_t offset) void set(std::size_t offset)
{ {
_offset = offset; _offset = offset;
@ -72,7 +63,7 @@ namespace sqlpp
os << " OFFSET " << _offset; os << " OFFSET " << _offset;
} }
std::size_t _offset = 0; std::size_t _offset;
}; };
} }

View File

@ -454,7 +454,7 @@ namespace sqlpp
}; };
} }
auto dynamic_limit() auto dynamic_limit(std::size_t limit = 0)
->set_limit_t<dynamic_limit_t> ->set_limit_t<dynamic_limit_t>
{ {
static_assert(not is_noop<From>::value, "cannot call limit() without a from()"); static_assert(not is_noop<From>::value, "cannot call limit() without a from()");
@ -467,7 +467,7 @@ namespace sqlpp
_group_by, _group_by,
_having, _having,
_order_by, _order_by,
{}, {limit},
_offset, _offset,
}; };
} }
@ -499,7 +499,7 @@ namespace sqlpp
}; };
} }
auto dynamic_offset() auto dynamic_offset(std::size_t offset = 0)
-> set_offset_t<dynamic_offset_t> -> set_offset_t<dynamic_offset_t>
{ {
static_assert(not is_noop<Limit>::value, "cannot call offset() without a limit"); static_assert(not is_noop<Limit>::value, "cannot call offset() without a limit");
@ -513,7 +513,7 @@ namespace sqlpp
_having, _having,
_order_by, _order_by,
_limit, _limit,
{}, {offset},
}; };
} }