Skip to content

Commit f976667

Browse files
committed
Support for scrooge's different method arguments on .find_by_sql && .find_every
1 parent 9756713 commit f976667

File tree

1 file changed

+11
-3
lines changed
  • lib/active_record/connection_adapters/mysqlplus_adapter/deferrable

1 file changed

+11
-3
lines changed

Diff for: lib/active_record/connection_adapters/mysqlplus_adapter/deferrable/macro.rb

+11-3
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,16 @@ def preload_associations_with_defer(records, associations, preload_options={})
7070
# ...
7171
#
7272
def find_by_sql_with_defer( sql, defer = false )
73-
if defer
73+
if defer && !defer.is_a?(Numeric)
7474
ActiveRecord::Deferrable::Result.new do
7575
find_by_sql_without_defer( sql )
7676
end
7777
else
78-
find_by_sql_without_defer( sql )
78+
if (@@find_by_sql_arity ||= method(:find_by_sql_without_defer).arity) == -2
79+
find_by_sql_without_defer( sql, defer )
80+
else
81+
find_by_sql_without_defer( sql )
82+
end
7983
end
8084
end
8185

@@ -111,7 +115,11 @@ def find_every_with_defer(options) #:nodoc:
111115
if include_associations.any? && references_eager_loaded_tables?(options)
112116
records = find_with_associations(options)
113117
else
114-
records = find_by_sql(construct_finder_sql(options))
118+
if Object.const_defined?(:Scrooge)
119+
records = find_by_sql(construct_finder_sql(options), options[:scrooge_callsite])
120+
else
121+
records = find_by_sql(construct_finder_sql(options))
122+
end
115123
if include_associations.any?
116124
preload_associations(records, preload_deferred_includes( include_associations, options ))
117125
end

0 commit comments

Comments
 (0)