-
Notifications
You must be signed in to change notification settings - Fork 126
fix(warnings): Fix warnings caused by order
and find_each
combination
#3877
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…tion As we use some default scopes on models and/or associations using `order`, a warning is logged when we call `find_each` on them. This commit fixes the warnings by using `unscope(:order)` before calling `find_each`. It also changes the `config.active_record.error_on_ignored_order` to `true` in the test environment to ensure we raise an error instead of logging.
vincent-pochet
approved these changes
Jun 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
julienbourdeau
approved these changes
Jun 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌
diegocharles
pushed a commit
that referenced
this pull request
Jul 11, 2025
…tion (#3877) ## Context As we use some default scopes on models and/or associations using `order`, a warning is logged when we call `find_each` on them. ## Description This commit fixes the warnings by using `unscope(:order)` before calling `find_each`. It also changes the `config.active_record.error_on_ignored_order` to `true` in the test environment to ensure we raise an error instead of logging. Example of failed spec: ```shell bundle exec rspec spec/services/charge_filters/create_or_update_batch_service_spec.rb 1) ChargeFilters::CreateOrUpdateBatchService when filter params is empty when there are existing filters with cascade_updates set to true and existing filters discards all filters and the related values that are inherited from parent Failure/Error: charge.filters.where(id: inherited_filter_ids).find_each { remove_filter(it) } ArgumentError: Scoped order is ignored, use :cursor with :order to configure custom order. # ./app/services/charge_filters/create_or_update_batch_service.rb:118:in 'block in ChargeFilters::CreateOrUpdateBatchService#remove_all' # ./app/services/charge_filters/create_or_update_batch_service.rb:116:in 'ChargeFilters::CreateOrUpdateBatchService#remove_all' # ./app/services/charge_filters/create_or_update_batch_service.rb:23:in 'ChargeFilters::CreateOrUpdateBatchService#call' # ./app/services/base_service.rb:243:in 'block in BaseService.call' # ./app/services/base_service.rb:237:in 'BaseService.call' # ./spec/services/charge_filters/create_or_update_batch_service_spec.rb:6:in 'block (2 levels) in <top (required)>' # ./spec/services/charge_filters/create_or_update_batch_service_spec.rb:96:in 'block (6 levels) in <top (required)>' # ./spec/services/charge_filters/create_or_update_batch_service_spec.rb:96:in 'block (5 levels) in <top (required)>' # ./spec/spec_helper.rb:160:in 'block (3 levels) in <top (required)>' # ./spec/spec_helper.rb:159:in 'block (2 levels) in <top (required)>' 2) ChargeFilters::CreateOrUpdateBatchService when filter params is empty when there are existing filters with cascade_updates set to true and existing filters does not discard filters and the related values that are defined on child Failure/Error: charge.filters.where(id: inherited_filter_ids).find_each { remove_filter(it) } ArgumentError: Scoped order is ignored, use :cursor with :order to configure custom order. # ./app/services/charge_filters/create_or_update_batch_service.rb:118:in 'block in ChargeFilters::CreateOrUpdateBatchService#remove_all' # ./app/services/charge_filters/create_or_update_batch_service.rb:116:in 'ChargeFilters::CreateOrUpdateBatchService#remove_all' # ./app/services/charge_filters/create_or_update_batch_service.rb:23:in 'ChargeFilters::CreateOrUpdateBatchService#call' # ./app/services/base_service.rb:243:in 'block in BaseService.call' # ./app/services/base_service.rb:237:in 'BaseService.call' # ./spec/services/charge_filters/create_or_update_batch_service_spec.rb:6:in 'block (2 levels) in <top (required)>' # ./spec/services/charge_filters/create_or_update_batch_service_spec.rb:101:in 'block (5 levels) in <top (required)>' # ./spec/spec_helper.rb:160:in 'block (3 levels) in <top (required)>' # ./spec/spec_helper.rb:159:in 'block (2 levels) in <top (required)>' Finished in 1.48 seconds (files took 1.87 seconds to load) 16 examples, 2 failures Failed examples: rspec ./spec/services/charge_filters/create_or_update_batch_service_spec.rb:95 # ChargeFilters::CreateOrUpdateBatchService when filter params is empty when there are existing filters with cascade_updates set to true and existing filters discards all filters and the related values that are inherited from parent rspec ./spec/services/charge_filters/create_or_update_batch_service_spec.rb:100 # ChargeFilters::CreateOrUpdateBatchService when filter params is empty when there are existing filters with cascade_updates set to true and existing filters does not discard filters and the related values that are defined on child ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
As we use some default scopes on models and/or associations using
order
, a warning is logged when we callfind_each
on them.Description
This PR fixes the warnings by using
unscope(:order)
before callingfind_each
. It also changes theconfig.active_record.error_on_ignored_order
totrue
in the test environment to ensure we raise an error instead of logging.Example of failed spec: