Skip to content

Extending unscope? #8

Open
Open
@danielpuglisi

Description

@danielpuglisi

Hi there

I'm currently building an API with geared_pagination and was wondering if it would make sense to add unscope(:select, :order, :group) to GearedPagination::Recordset#records_count as it otherwise causes some trouble with more complex queries. I don't think select, order and group are required here. But maybe I'm missing something?

For example here is a query that I'm trying to resolve:

Event.joins(:event_parts)
  .where('event_parts.ends_at > ?', Time.zone.now)
  .order(Arel.sql('min(event_parts.starts_at)'))
  .group('events.id')
  .preload(:event_parts)

Which results in an TypeError: no implicit conversion of Integer into Hash exception because the count result is grouped by events.id.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions