Skip to content

Extending unscope? #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
danielpuglisi opened this issue Feb 22, 2019 · 1 comment · May be fixed by #49
Open

Extending unscope? #8

danielpuglisi opened this issue Feb 22, 2019 · 1 comment · May be fixed by #49

Comments

@danielpuglisi
Copy link

danielpuglisi commented Feb 22, 2019

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.

@smridge smridge linked a pull request Dec 5, 2022 that will close this issue
@smridge
Copy link

smridge commented Dec 5, 2022

I realized this issue was here after I ran into it myself. This PR #49 fixes it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants