Deprecated: Function get_magic_quotes_gpc() is deprecated in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 99

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 619

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1169

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176
8000 Select up to 10 by billy1624 · Pull Request #2553 · SeaQL/sea-orm · GitHub
Nothing Special   »   [go: up one dir, main page]

Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 63 additions & 61 deletions src/executor/cursor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
ConnectionTrait, DbErr, EntityTrait, FromQueryResult, Identity, IdentityOf, IntoIdentity,
PartialModelTrait, PrimaryKeyToColumn, QueryOrder, QuerySelect, Select, SelectModel,
SelectThree, SelectThreeModel, SelectTwo, SelectTwoModel, SelectorTrait,
PartialModelTrait, PrimaryKeyToColumn, QueryOrder, QuerySelect, Select, SelectModel, SelectTwo,
SelectTwoModel, SelectorTrait,
};
use sea_query::{
Condition, DynIden, Expr, IntoValueTuple, Order, SeaRc, SelectStatement, SimpleExpr, Value,
Expand Down Expand Up @@ -398,27 +398,27 @@ where
}
}

impl<E, F, M, N> CursorTrait for SelectTwo<E, F>
where
E: EntityTrait<Model = M>,
F: EntityTrait<Model = N>,
M: FromQueryResult + Sized + Send + Sync,
N: FromQueryResult + Sized + Send + Sync,
{
type Selector = SelectTwoModel<M, N>;
macro_rules! impl_cursor_trait {
( $select_struct:ident <$($select_generics:ident),+>, $model_struct:ident <$($model_generics:ident),+> ) => {
impl<$($select_generics),*, $($model_generics),*> CursorTrait for crate::$select_struct<$($select_generics),*>
where
$($select_generics: EntityTrait<Model = $model_generics>,)*
$($model_generics: FromQueryResult + Sized + Send + Sync,)*
{
type Selector = crate::$model_struct<$($model_generics,)*>;
}
}
}

impl<E, F, G, M, N, O> CursorTrait for SelectThree<E, F, G>
where
E: EntityTrait<Model = M>,
F: EntityTrait<Model = N>,
G: EntityTrait<Model = O>,
M: FromQueryResult + Sized + Send + Sync,
N: FromQueryResult + Sized + Send + Sync,
O: FromQueryResult + Sized + Send + Sync,
{
type Selector = SelectThreeModel<M, N, O>;
}
impl_cursor_trait!(SelectTwo<E, F>, SelectTwoModel<O, P>);
impl_cursor_trait!(SelectThree<E, F, G>, SelectThreeModel<O, P, Q>);
impl_cursor_trait!(SelectFour<E, F, G, H>, SelectFourModel<O, P, Q, R>);
impl_cursor_trait!(SelectFive<E, F, G, H, I>, SelectFiveModel<O, P, Q, R, S>);
impl_cursor_trait!(SelectSix<E, F, G, H, I, J>, SelectSixModel<O, P, Q, R, S, T>);
impl_cursor_trait!(SelectSeven<E, F, G, H, I, J, K>, SelectSevenModel<O, P, Q, R, S, T, U>);
impl_cursor_trait!(SelectEight<E, F, G, H, I, J, K, L>, SelectEightModel<O, P, Q, R, S, T, U, V>);
impl_cursor_trait!(SelectNine<E, F, G, H, I, J, K, L, M>, SelectNineModel<O, P, Q, R, S, T, U, V, W>);
impl_cursor_trait!(SelectTen<E, F, G, H, I, J, K, L, M, N>, SelectTenModel<O, P, Q, R, S, T, U, V, W, X>);

impl<E, F, M, N> SelectTwo<E, F>
where
Expand Down Expand Up @@ -472,51 +472,53 @@ where
}
}

impl<E, F, G, M, N, O> SelectThree<E, F, G>
where
E: EntityTrait<Model = M>,
F: EntityTrait<Model = N>,
G: EntityTrait<Model = O>,
M: FromQueryResult + Sized + Send + Sync,
N: FromQueryResult + Sized + Send + Sync,
O: FromQueryResult + Sized + Send + Sync,
{
/// Convert into a cursor using column of first entity
pub fn cursor_by<C>(self, order_columns: C) -> Cursor<SelectThreeModel<M, N, O>>
where
C: IdentityOf<E>,
{
let mut cursor = Cursor::new(
self.query,
SeaRc::new(E::default()),
order_columns.identity_of(),
);
{
let primary_keys: Vec<(DynIden, Identity)> = <F::PrimaryKey as Iterable>::iter()
.map(|pk| {
(
SeaRc::new(F::default()),
Identity::Unary(SeaRc::new(pk.into_column())),
)
})
.collect();
cursor.set_secondary_order_by(primary_keys);
}
macro_rules! impl_cursor_by {
( $select_struct:ident <$first_select_generics:ident, $($select_generics:ident),+>, $model_struct:ident <$first_model_generics:ident, $($model_generics:ident),+> ) => {
impl<$first_select_generics, $($select_generics),*, $first_model_generics, $($model_generics),*> crate::$select_struct<$first_select_generics, $($select_generics),*>
where
$first_select_generics: EntityTrait<Model = $first_model_generics>,
$($select_generics: EntityTrait<Model = $model_generics>,)*
$first_model_generics: FromQueryResult + Sized + Send + Sync,
$($model_generics: FromQueryResult + Sized + Send + Sync,)*
{
let primary_keys: Vec<(DynIden, Identity)> = <G::PrimaryKey as Iterable>::iter()
.map(|pk| {
(
SeaRc::new(G::default()),
Identity::Unary(SeaRc::new(pk.into_column())),
)
})
.collect();
cursor.set_secondary_order_by(primary_keys);
#[doc ="Convert into a cursor using column of first entity"]
pub fn cursor_by<C>(self, order_columns: C) -> Cursor<crate::$model_struct<$first_model_generics, $($model_generics),*>>
where
C: IdentityOf<$first_select_generics>,
{
let mut cursor = Cursor::new(
self.query,
SeaRc::new($first_select_generics::default()),
Copy link
Copilot AI Apr 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The macro calls default() on the entity type parameter without an explicit Default bound. Ensure that all entity types passed to this macro implement Default to avoid potential runtime issues.

Copilot uses AI. Check for mistakes.

order_columns.identity_of(),
);
$(
{
let primary_keys: Vec<(DynIden, Identity)> = <$select_generics::PrimaryKey as Iterable>::iter()
.map(|pk| {
(
SeaRc::new($select_generics::default()),
Identity::Unary(SeaRc::new(pk.into_column())),
)
})
.collect();
cursor.set_secondary_order_by(primary_keys);
}
)*
cursor
}
}
cursor
}
}

impl_cursor_by!(SelectThree<E, F, G>, SelectThreeModel<O, P, Q>);
impl_cursor_by!(SelectFour<E, F, G, H>, SelectFourModel<O, P, Q, R>);
impl_cursor_by!(SelectFive<E, F, G, H, I>, SelectFiveModel<O, P, Q, R, S>);
impl_cursor_by!(SelectSix<E, F, G, H, I, J>, SelectSixModel<O, P, Q, R, S, T>);
impl_cursor_by!(SelectSeven<E, F, G, H, I, J, K>, SelectSevenModel<O, P, Q, R, S, T, U>);
impl_cursor_by!(SelectEight<E, F, G, H, I, J, K, L>, SelectEightModel<O, P, Q, R, S, T, U, V>);
impl_cursor_by!(SelectNine<E, F, G, H, I, J, K, L, M>, SelectNineModel<O, P, Q, R, S, T, U, V, W>);
impl_cursor_by!(SelectTen<E, F, G, H, I, J, K, L, M, N>, SelectTenModel<O, P, Q, R, S, T, U, V, W, X>);

#[cfg(test)]
#[cfg(feature = "mock")]
mod tests {
Expand Down
53 changes: 24 additions & 29 deletions src/executor/paginator.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
error::*, ConnectionTrait, DbBackend, EntityTrait, FromQueryResult, Select, SelectModel,
SelectThree, SelectThreeModel, SelectTwo, SelectTwoModel, Selector, SelectorRaw, SelectorTrait,
Selector, SelectorRaw, SelectorTrait,
};
use async_stream::stream;
use futures_util::Stream;
Expand Down Expand Up @@ -285,37 +285,32 @@ where
}
}

impl<'db, C, M, N, E, F> PaginatorTrait<'db, C> for SelectTwo<E, F>
where
C: ConnectionTrait,
E: EntityTrait<Model = M>,
F: EntityTrait<Model = N>,
M: FromQueryResult + Sized + Send + Sync + 'db,
N: FromQueryResult + Sized + Send + Sync + 'db,
{
type Selector = SelectTwoModel<M, N>;

fn paginate(self, db: &'db C, page_size: u64) -> Paginator<'db, C, Self::Selector> {
self.into_model().paginate(db, page_size)
macro_rules! impl_paginator_trait {
( $select_struct:ident <$($select_generics:ident),+>, $model_struct:ident <$($model_generics:ident),+> ) => {
impl<'db, C, $($select_generics),*, $($model_generics),*> PaginatorTrait<'db, C> for crate::$select_struct<$($select_generics),*>
where
C: ConnectionTrait,
$($select_generics: EntityTrait<Model = $model_generics>,)*
$($model_generics: FromQueryResult + Sized + Send + Sync + 'db,)*
{
type Selector = crate::$model_struct<$($model_generics),*>;

fn paginate(self, db: &'db C, page_size: u64) -> Paginator<'db, C, Self::Selector> {
self.into_model().paginate(db, page_size)
}
}
}
}

impl<'db, C, M, N, O, E, F, G> PaginatorTrait<'db, C> for SelectThree<E, F, G>
where
C: ConnectionTrait,
E: EntityTrait<Model = M>,
F: EntityTrait<Model = N>,
G: EntityTrait<Model = O>,
M: FromQueryResult + Sized + Send + Sync + 'db,
N: FromQueryResult + Sized + Send + Sync + 'db,
O: FromQueryResult + Sized + Send + Sync + 'db,
{
type Selector = SelectThreeModel<M, N, O>;

fn paginate(self, db: &'db C, page_size: u64) -> Paginator<'db, C, Self::Selector> {
self.into_model().paginate(db, page_size)
}
}
impl_paginator_trait!(SelectTwo<E, F>, SelectTwoModel<O, P>);
impl_paginator_trait!(SelectThree<E, F, G>, SelectThreeModel<O, P, Q>);
impl_paginator_trait!(SelectFour<E, F, G, H>, SelectFourModel<O, P, Q, R>);
impl_paginator_trait!(SelectFive<E, F, G, H, I>, SelectFiveModel<O, P, Q, R, S>);
impl_paginator_trait!(SelectSix<E, F, G, H, I, J>, SelectSixModel<O, P, Q, R, S, T>);
impl_paginator_trait!(SelectSeven<E, F, G, H, I, J, K>, SelectSevenModel<O, P, Q, R, S, T, U>);
impl_paginator_trait!(SelectEight<E, F, G, H, I, J, K, L>, SelectEightModel<O, P, Q, R, S, T, U, V>);
impl_paginator_trait!(SelectNine<E, F, G, H, I, J, K, L, M>, SelectNineModel<O, P, Q, R, S, T, U, V, W>);
impl_paginator_trait!(SelectTen<E, F, G, H, I, J, K, L, M, N>, SelectTenModel<O, P, Q, R, S, T, U, V, W, X>);

#[cfg(test)]
#[cfg(feature = "mock")]
Expand Down
Loading
0