Skip to main content

saola_query_builder/
query_arguments_ext.rs

1use query_structure::QueryArguments;
2
3pub trait QueryArgumentsExt {
4    /// If we need to take rows before a cursor position, then we need to reverse the order in SQL.
5    fn needs_reversed_order(&self) -> bool;
6
7    /// Checks whether any form of memory processing is needed, or we could just return the records
8    /// as they are. This is useful to avoid turning an existing collection of records into an
9    /// iterator and re-collecting it back with no changes.
10    #[cfg(feature = "relation_joins")]
11    fn needs_inmemory_processing_with_joins(&self) -> bool;
12}
13
14impl QueryArgumentsExt for QueryArguments {
15    fn needs_reversed_order(&self) -> bool {
16        self.take.is_reversed()
17    }
18
19    #[cfg(feature = "relation_joins")]
20    fn needs_inmemory_processing_with_joins(&self) -> bool {
21        use query_structure::RelationLoadStrategy;
22
23        self.needs_reversed_order()
24            || self.requires_inmemory_distinct(RelationLoadStrategy::Join)
25            || self.requires_inmemory_pagination(RelationLoadStrategy::Join)
26    }
27}