提交 de239066 编写于 作者: S Sean Griffin

Stop using `Arel::Table.engine`

We never actually make use of it on the table, since we're constructing
the select manager manually. It looks like if we ever actually were
grabbing it from the table, we're grossly misusing it since it's meant
to vary by AR class.

Its existence on `Arel::Table` appears to be purely for convenience
methods that are never used outside of tests. However, in production
code it just complicates construction of the tables on the rails side,
and the plan is to remove it from `Arel::Table` entirely. I'm not
convinced it needs to live on `SelectManager`, etc either.
上级 5493d16d
......@@ -235,7 +235,7 @@ def ===(object)
# scope :published_and_commented, -> { published.and(self.arel_table[:comments_count].gt(0)) }
# end
def arel_table # :nodoc:
@arel_table ||= Arel::Table.new(table_name, arel_engine)
@arel_table ||= Arel::Table.new(table_name)
end
# Returns the Arel engine.
......
......@@ -25,7 +25,7 @@ def self.build_from_hash(klass, attributes, default_table)
if value.empty?
queries << '1=0'
else
table = Arel::Table.new(column, default_table.engine)
table = Arel::Table.new(column)
association = klass._reflect_on_association(column)
value.each do |k, v|
......@@ -37,7 +37,7 @@ def self.build_from_hash(klass, attributes, default_table)
if column.include?('.')
table_name, column = column.split('.', 2)
table = Arel::Table.new(table_name, default_table.engine)
table = Arel::Table.new(table_name)
end
queries.concat expand(klass, table, column, value)
......
......@@ -858,7 +858,7 @@ def arel # :nodoc:
private
def build_arel
arel = Arel::SelectManager.new(table.engine, table)
arel = Arel::SelectManager.new(klass.arel_engine, table)
build_joins(arel, joins_values.flatten) unless joins_values.empty?
......
......@@ -93,7 +93,7 @@ def sanitize_sql_hash_for_conditions(attrs, default_table_name = self.table_name
attrs = PredicateBuilder.resolve_column_aliases self, attrs
attrs = expand_hash_conditions_for_aggregates(attrs)
table = Arel::Table.new(table_name, arel_engine).alias(default_table_name)
table = Arel::Table.new(table_name).alias(default_table_name)
PredicateBuilder.build_from_hash(self, attrs, table).map { |b|
connection.visitor.compile b
}.join(' AND ')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册