1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Simply methods for checking eager loaded tables references in the query

This commit is contained in:
Pratik Naik 2010-01-03 03:00:14 +05:30
parent 4c5b5024c3
commit a9c790e10f

View file

@ -1830,22 +1830,22 @@ module ActiveRecord
end
# Checks if the conditions reference a table other than the current model table
def include_eager_conditions?(options, tables = nil, joined_tables = nil)
((tables || conditions_tables(options)) - (joined_tables || joined_tables(options))).any?
def include_eager_conditions?(options, joined_tables)
(conditions_tables(options) - joined_tables).any?
end
# Checks if the query order references a table other than the current model's table.
def include_eager_order?(options, tables = nil, joined_tables = nil)
((tables || order_tables(options)) - (joined_tables || joined_tables(options))).any?
def include_eager_order?(options, joined_tables)
(order_tables(options) - joined_tables).any?
end
def include_eager_select?(options, joined_tables = nil)
(selects_tables(options) - (joined_tables || joined_tables(options))).any?
def include_eager_select?(options, joined_tables)
(selects_tables(options) - joined_tables).any?
end
def references_eager_loaded_tables?(options)
joined_tables = joined_tables(options)
include_eager_order?(options, nil, joined_tables) || include_eager_conditions?(options, nil, joined_tables) || include_eager_select?(options, joined_tables)
include_eager_order?(options, joined_tables) || include_eager_conditions?(options, joined_tables) || include_eager_select?(options, joined_tables)
end
def using_limitable_reflections?(reflections)