Skip to content

Commit 0ebcb0d

Browse files
author
Alexei Pastuchov
committed
ApplyOffset for diesel::mysql::Mysql sets mandatory limit parameter
diesel limits bei u64::MAX https://github.com/diesel-rs/diesel/blob/968e7f79cf6953eb66ddb4256c1e8d5991dc808d/diesel/src/mysql/query_builder/limit_offset.rs#L57 Since GraphQL doesn't know unsigned types, limit is restricted i64::MAX
1 parent 0da2814 commit 0ebcb0d

File tree

1 file changed

+9
-4
lines changed
  • wundergraph/src/query_builder/selection

1 file changed

+9
-4
lines changed

wundergraph/src/query_builder/selection/offset.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::juniper_ext::FromLookAheadValue;
66
use crate::query_builder::selection::{BoxedQuery, LoadingHandler};
77
use crate::scalar::WundergraphScalarValue;
88
use diesel::backend::Backend;
9-
#[cfg(feature = "sqlite")]
9+
#[cfg(any(feature = "sqlite", feature = "mysql"))]
1010
use diesel::query_dsl::methods::LimitDsl;
1111
#[cfg(any(feature = "postgres", feature = "sqlite", feature = "mysql"))]
1212
use diesel::query_dsl::methods::OffsetDsl;
@@ -85,13 +85,18 @@ impl ApplyOffset for diesel::mysql::Mysql {
8585
{
8686
use juniper::LookAheadMethods;
8787
if let Some(offset) = select.argument("offset") {
88-
Ok(<_ as OffsetDsl>::offset(
88+
let q = <_ as OffsetDsl>::offset(
8989
query,
9090
i64::from_look_ahead(offset.value())
9191
.ok_or(WundergraphError::CouldNotBuildFilterArgument)?,
92-
))
92+
);
93+
if select.argument("limit").is_some() {
94+
Ok(q)
95+
} else {
96+
Ok(<_ as LimitDsl>::limit(q, std::i64::MAX))
97+
}
9398
} else {
9499
Ok(query)
95100
}
96101
}
97-
}
102+
}

0 commit comments

Comments
 (0)