Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Unable to resolve constant BatchEnumerator #476

Open
billy1kaplan opened this issue Jan 6, 2022 · 1 comment
Open

Unable to resolve constant BatchEnumerator #476

billy1kaplan opened this issue Jan 6, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@billy1kaplan
Copy link

billy1kaplan commented Jan 6, 2022

Describe the bug:

After running bundle exec rake rails_rbi:models, many files no longer typecheck with this error:

Unable to resolve constant BatchEnumerator
    ).returns(ActiveRecord::Batches::BatchEnumerator)

This is surprising to me because I see this definition in sorbet/rbi/gems/activerecord.rbi:3845:

class ActiveRecord::Batches::BatchEnumerator
  def delete_all; end
  def destroy_all; end
  def each; end
  def each_record; end
  def initialize(relation:, of: nil, start: nil, finish: nil); end
  def update_all(updates); end
  include Enumerable
end

Doing a bit of searching, I found this issue which describes a similar problem but seems to have been resolved: #355

I'm not sure if this is an issue specifically with sorbet-rails, sorbet, or (most likely) with my understanding of how this should work. Any help is much appreciated!

Steps to reproduce:

  1. Run bundle exec rake rails_rbi:models
  2. Run bundle exec srb tc

Expected behavior:
Expect to find this constant that sorbet-rails is using to generate type definitions.

Versions:

  • Ruby: 2.7.2
  • Rails: 6.1.4.1
  • Sorbet: 0.5.9449
  • Sorbet-Rails: 0.7.27
@billy1kaplan billy1kaplan added the bug Something isn't working label Jan 6, 2022
@billy1kaplan
Copy link
Author

As a temporary workaround, can probably add this class to todo.rbi.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant