Browse Source

let Finder::page() takes a page number and not an offset

master
Tomasz Sowa 4 days ago
parent
commit
bc92654be9
  1. 2
      src/dbexpression.cpp
  2. 3
      src/dbexpression.h
  3. 4
      src/finder.h
  4. 2
      src/postgresqlexpression.cpp

2
src/dbexpression.cpp

@ -296,7 +296,7 @@ DbExpression & DbExpression::group_end(pt::TextStream & stream)
DbExpression & DbExpression::page(pt::TextStream & stream, size_t page_number, size_t page_size)
{
stream << " LIMIT " << page_number << "," << page_size << " ";
stream << " LIMIT " << (page_number*page_size) << "," << page_size << " ";
return *this;
}

3
src/dbexpression.h

@ -64,6 +64,9 @@ public:
virtual DbExpression & group_and(pt::TextStream & stream);
virtual DbExpression & group_end(pt::TextStream & stream);
/*
* page_number starts from zero (it's a number of a page, not an offset)
*/
virtual DbExpression & page(pt::TextStream & stream, size_t page_number, size_t page_size);
template<typename FieldValue>

4
src/finder.h

@ -589,7 +589,9 @@ public:
/*
* page_number start from zero (it's a number of a page, not an offset)
*/
Finder<ModelClass> & page(size_t page_number, size_t page_size)
{
if( out_stream && db_expression )

2
src/postgresqlexpression.cpp

@ -100,7 +100,7 @@ void PostgreSQLExpression::esc(const pt::Date & date, pt::TextStream & stream, c
DbExpression & PostgreSQLExpression::page(pt::TextStream & stream, size_t page_number, size_t page_size)
{
stream << " OFFSET " << page_number << " LIMIT " << page_size << " ";
stream << " OFFSET " << (page_number*page_size) << " LIMIT " << page_size << " ";
return *this;
}

Loading…
Cancel
Save