@@ -17,8 +17,8 @@ use std::str::FromStr;
17
17
use std:: sync:: Arc ;
18
18
19
19
const MAX_PAGE_BEFORE_SUSPECTED_BOT : u32 = 10 ;
20
- const DEFAULT_PER_PAGE : u32 = 10 ;
21
- const MAX_PER_PAGE : u32 = 100 ;
20
+ const DEFAULT_PER_PAGE : i64 = 10 ;
21
+ const MAX_PER_PAGE : i64 = 100 ;
22
22
23
23
#[ derive( Debug , Clone , PartialEq , Eq ) ]
24
24
pub ( crate ) enum Page {
@@ -30,7 +30,7 @@ pub(crate) enum Page {
30
30
#[ derive( Debug , Clone ) ]
31
31
pub ( crate ) struct PaginationOptions {
32
32
pub ( crate ) page : Page ,
33
- pub ( crate ) per_page : u32 ,
33
+ pub ( crate ) per_page : i64 ,
34
34
}
35
35
36
36
impl PaginationOptions {
@@ -42,9 +42,9 @@ impl PaginationOptions {
42
42
}
43
43
}
44
44
45
- pub ( crate ) fn offset ( & self ) -> Option < u32 > {
45
+ pub ( crate ) fn offset ( & self ) -> Option < i64 > {
46
46
if let Page :: Numeric ( p) = self . page {
47
- Some ( ( p - 1 ) * self . per_page )
47
+ Some ( ( p - 1 ) as i64 * self . per_page )
48
48
} else {
49
49
None
50
50
}
@@ -238,10 +238,9 @@ where
238
238
out. push_sql ( "SELECT *, COUNT(*) OVER () FROM (" ) ;
239
239
self . query . walk_ast ( out. reborrow ( ) ) ?;
240
240
out. push_sql ( ") t LIMIT " ) ;
241
- out. push_bind_param :: < BigInt , _ > ( ( self . options . per_page as & i64 ) ) ?;
241
+ out. push_bind_param :: < BigInt , _ > ( & self . options . per_page ) ?;
242
242
if let Some ( offset) = self . options . offset ( ) {
243
- out. push_sql ( " OFFSET " ) ;
244
- out. push_bind_param :: < BigInt , _ > ( & ( offset as i64 ) ) ?;
243
+ out. push_sql ( format ! ( " OFFSET {}" , offset) . as_str ( ) ) ;
245
244
}
246
245
Ok ( ( ) )
247
246
}
0 commit comments