saola-query-builder 0.1.0

Generic query builder for Saola ORM
Documentation
use query_structure::QueryArguments;

pub trait QueryArgumentsExt {
    /// If we need to take rows before a cursor position, then we need to reverse the order in SQL.
    fn needs_reversed_order(&self) -> bool;

    /// Checks whether any form of memory processing is needed, or we could just return the records
    /// as they are. This is useful to avoid turning an existing collection of records into an
    /// iterator and re-collecting it back with no changes.
    #[cfg(feature = "relation_joins")]
    fn needs_inmemory_processing_with_joins(&self) -> bool;
}

impl QueryArgumentsExt for QueryArguments {
    fn needs_reversed_order(&self) -> bool {
        self.take.is_reversed()
    }

    #[cfg(feature = "relation_joins")]
    fn needs_inmemory_processing_with_joins(&self) -> bool {
        use query_structure::RelationLoadStrategy;

        self.needs_reversed_order()
            || self.requires_inmemory_distinct(RelationLoadStrategy::Join)
            || self.requires_inmemory_pagination(RelationLoadStrategy::Join)
    }
}