-
-
Notifications
You must be signed in to change notification settings - Fork 550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PaginatorTrait for SelectorRaw #500
Comments
Hey @cemoktra, good suggestions! Currently, we have no plans on doing it. I would open this for the community, any contributions are welcomed! Ping us if you need any help along the way :P |
Hi, I would like to contribute to solving this issue. impl<'db, C, S> PaginatorTrait<'db, C> for SelectorRaw<S>
where
C: ConnectionTrait,
S: SelectorTrait + Send + Sync + 'db,
{
type Selector = S;
fn paginate(self, db: &'db C, page_size: usize) -> Paginator<'db, C, S> {
let mut sql = self.stmt.sql.trim();
if sql.starts_with("SELECT") || sql.starts_with("select") {
sql = &sql[6..];
}
let mut query = SelectStatement::new();
query.expr(Expr::cust(sql));
Paginator {
query,
page: 0,
page_size,
db,
selector: PhantomData,
}
}
} |
Hey @shinbunbun, thank you so much for reaching out!! I think we can assume the statement is a select statement. We can explicitly mention this assumption on the method docs. So, this part and be ignored. if sql.starts_with("SELECT") || sql.starts_with("select") {
sql = &sql[6..];
}
if have_values {
query.expr(Expr::cust_with_values(sql, values));
} else {
query.expr(Expr::cust(sql));
} All in all your implementation looks good! :P |
Thank you for your reply! |
@billy1624 |
Hi,
it seems this is not implemented at the moment, any plans on doing it?
The text was updated successfully, but these errors were encountered: