Skip to content

Commit 5313ccd

Browse files
p-alikweiznich
authored and
Alexei Pastuchov
committed
Update wundergraph/src/query_builder/selection/offset.rs
import LimitDsl for sqlite and mysql Co-authored-by: Georg Semmler <[email protected]>
1 parent 26e10cc commit 5313ccd

File tree

1 file changed

+6
-1
lines changed
  • wundergraph/src/query_builder/selection

1 file changed

+6
-1
lines changed

wundergraph/src/query_builder/selection/offset.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use diesel::backend::Backend;
1010
use diesel::query_dsl::methods::LimitDsl;
1111
#[cfg(any(feature = "postgres", feature = "sqlite", feature = "mysql"))]
1212
use diesel::query_dsl::methods::OffsetDsl;
13-
1413
use juniper::LookAheadSelection;
1514

1615
/// A trait abstracting over the different behaviour of limit/offset
@@ -93,6 +92,12 @@ impl ApplyOffset for diesel::mysql::Mysql {
9392
if select.argument("limit").is_some() {
9493
Ok(q)
9594
} else {
95+
// Mysql requires a limit clause in front of any offset clause
96+
// The documentation proposes the following:
97+
// > To retrieve all rows from a certain offset up to the end of the
98+
// > result set, you can use some large number for the second parameter.
99+
// https://dev.mysql.com/doc/refman/8.0/en/select.html
100+
// Therefore we just use i64::MAX as limit here
96101
Ok(<_ as LimitDsl>::limit(q, std::i64::MAX))
97102
}
98103
} else {

0 commit comments

Comments
 (0)