diff --git a/lib/quo/collection_backed_query.rb b/lib/quo/collection_backed_query.rb index 2846c4c..65e14e5 100644 --- a/lib/quo/collection_backed_query.rb +++ b/lib/quo/collection_backed_query.rb @@ -103,11 +103,6 @@ def to_collection self end - # @rbs return: Object & Enumerable[untyped] - def unwrap - underlying_query - end - private # @rbs override diff --git a/lib/quo/query.rb b/lib/quo/query.rb index d69511b..a1458b6 100644 --- a/lib/quo/query.rb +++ b/lib/quo/query.rb @@ -367,8 +367,15 @@ def transformer # The configured query is the underlying query with paging def configured_query #: ActiveRecord::Relation q = underlying_query - return q unless paged? && q.is_a?(ActiveRecord::Relation) - q.offset(offset).limit(sanitised_page_size) + return q unless paged? + + if q.is_a?(ActiveRecord::Relation) + q.offset(offset).limit(sanitised_page_size) + elsif q.respond_to?(:[]) + q[offset, sanitised_page_size] + else + q + end end def sanitised_page_size #: Integer diff --git a/sig/generated/quo/collection_backed_query.rbs b/sig/generated/quo/collection_backed_query.rbs index 2399616..f55794a 100644 --- a/sig/generated/quo/collection_backed_query.rbs +++ b/sig/generated/quo/collection_backed_query.rbs @@ -36,6 +36,9 @@ module Quo # @rbs override def group: ... + # @rbs override + def includes: ... + # The default implementation of `query` calls `collection` and preloads the includes, however you can also # override this method to return an ActiveRecord::Relation or any other query-like object as usual in a Query object. # @rbs return: Object & Enumerable[untyped] @@ -52,9 +55,6 @@ module Quo # @rbs override def to_collection: ... - # @rbs return: Object & Enumerable[untyped] - def unwrap: () -> (Object & Enumerable[untyped]) - private # @rbs override diff --git a/sig/generated/quo/query.rbs b/sig/generated/quo/query.rbs index 85083d9..ae8d98c 100644 --- a/sig/generated/quo/query.rbs +++ b/sig/generated/quo/query.rbs @@ -127,6 +127,12 @@ module Quo # Gets the count of all results ignoring the current page and page size (if set). def count: () -> Integer + # Total number of items without paging applied. + def total_count: () -> Integer + + # Alias for count + def size: () -> Integer + # Gets the actual count of elements in the page of results (assuming paging is being used, otherwise the count of # all results) def page_count: () -> Integer