mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove useless arel_engine
`arel_engine` is only used in `raise_record_not_found_exception!` to use `engine.connection` (and `connection.visitor`) in `arel.where_sql`. https://github.com/rails/arel/blob/v8.0.0/lib/arel/select_manager.rb#L183 But `klass.connection` will work as expected even if not using `arel_engine` (described by `test_connection`). So `arel_engine` is no longer needed.
This commit is contained in:
parent
fbade51248
commit
a0ebab52b2
4 changed files with 3 additions and 19 deletions
|
@ -263,16 +263,6 @@ module ActiveRecord
|
|||
@arel_table ||= Arel::Table.new(table_name, type_caster: type_caster)
|
||||
end
|
||||
|
||||
# Returns the Arel engine.
|
||||
def arel_engine # :nodoc:
|
||||
@arel_engine ||=
|
||||
if Base == self || connection_handler.retrieve_connection_pool(connection_specification_name)
|
||||
self
|
||||
else
|
||||
superclass.arel_engine
|
||||
end
|
||||
end
|
||||
|
||||
def arel_attribute(name, table = arel_table) # :nodoc:
|
||||
name = attribute_alias(name) if attribute_alias?(name)
|
||||
table[name]
|
||||
|
|
|
@ -467,7 +467,6 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def reload_schema_from_cache
|
||||
@arel_engine = nil
|
||||
@arel_table = nil
|
||||
@column_names = nil
|
||||
@attribute_types = nil
|
||||
|
|
|
@ -329,7 +329,7 @@ module ActiveRecord
|
|||
# the expected number of results should be provided in the +expected_size+
|
||||
# argument.
|
||||
def raise_record_not_found_exception!(ids = nil, result_size = nil, expected_size = nil, key = primary_key) # :nodoc:
|
||||
conditions = arel.where_sql(@klass.arel_engine)
|
||||
conditions = arel.where_sql(@klass)
|
||||
conditions = " [#{conditions}]" if conditions
|
||||
name = @klass.name
|
||||
|
||||
|
|
|
@ -90,14 +90,9 @@ class MultipleDbTest < ActiveRecord::TestCase
|
|||
assert_equal "Ruby Developer", Entrant.find(1).name
|
||||
end
|
||||
|
||||
def test_arel_table_engines
|
||||
assert_not_equal Entrant.arel_engine, Bird.arel_engine
|
||||
assert_not_equal Entrant.arel_engine, Course.arel_engine
|
||||
end
|
||||
|
||||
def test_connection
|
||||
assert_equal Entrant.arel_engine.connection.object_id, Bird.arel_engine.connection.object_id
|
||||
assert_not_equal Entrant.arel_engine.connection.object_id, Course.arel_engine.connection.object_id
|
||||
assert_same Entrant.connection, Bird.connection
|
||||
assert_not_same Entrant.connection, Course.connection
|
||||
end
|
||||
|
||||
unless in_memory_db?
|
||||
|
|
Loading…
Reference in a new issue