From 08a748118377f22823e06315f57db16e1ce3a7c3 Mon Sep 17 00:00:00 2001 From: Scott Ringwelski Date: Mon, 1 Feb 2016 20:17:17 -0800 Subject: Add initial support for allowing an error on order or limit of queries being ignored in batches add some documentation and add 4 tests regarding error vs. warning behavior fix a typo when referring to the message go back to default in tests so that ordering is not important. use a constant instead of method. fix assert_nothing_raised call. use self.klass to allow per class configuration remove logger warn assets as that is tested elsewhere. pass error_on_ignore through find_each and find_in_batches also. add blocks to the finds so that the code is actually executed put the setting back to default in an ensure Add a changelog entry --- activerecord/lib/active_record/core.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activerecord/lib/active_record/core.rb') diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 475a298467..bed0cf9eea 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -70,6 +70,14 @@ module ActiveRecord mattr_accessor :schema_format, instance_writer: false self.schema_format = :ruby + ## + # :singleton-method: + # Specifies if an error should be raised on query limit or order being + # ignored when doing batch queries. Useful in applications where the + # limit or scope being ignored is error-worthy, rather than a warning. + mattr_accessor :error_on_ignored_order_or_limit, instance_writer: false + self.error_on_ignored_order_or_limit = false + ## # :singleton-method: # Specify whether or not to use timestamps for migration versions -- cgit v1.2.3