diff options
Diffstat (limited to 'lib/arel')
-rw-r--r-- | lib/arel/table.rb | 5 | ||||
-rw-r--r-- | lib/arel/visitors/oracle.rb | 4 | ||||
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 2 | ||||
-rw-r--r-- | lib/arel/visitors/visitor.rb | 9 |
4 files changed, 13 insertions, 7 deletions
diff --git a/lib/arel/table.rb b/lib/arel/table.rb index 189fb8eb94..32e3d84099 100644 --- a/lib/arel/table.rb +++ b/lib/arel/table.rb @@ -113,7 +113,10 @@ primary_key (#{caller.first}) is deprecated and will be removed in Arel 4.0.0 end def hash - [@name, @engine, @aliases, @table_alias].hash + # Perf note: aliases, table alias and engine is excluded from the hash + # aliases can have a loop back to this table breaking hashes in parent + # relations, for the vast majority of cases @name is unique to a query + @name.hash end def eql? other diff --git a/lib/arel/visitors/oracle.rb b/lib/arel/visitors/oracle.rb index b58d7338ef..b6f7b4cc3c 100644 --- a/lib/arel/visitors/oracle.rb +++ b/lib/arel/visitors/oracle.rb @@ -8,7 +8,7 @@ module Arel # if need to select first records without ORDER BY and GROUP BY and without DISTINCT # then can use simple ROWNUM in WHERE clause - if o.limit && o.orders.empty? && !o.offset && o.cores.first.projections.first !~ /^DISTINCT / + if o.limit && o.orders.empty? && !o.offset && o.cores.first.set_quantifier.class.to_s !~ /Distinct/ o.cores.last.wheres.push Nodes::LessThanOrEqual.new( Nodes::SqlLiteral.new('ROWNUM'), o.limit.expr ) @@ -83,7 +83,7 @@ module Arel return o if o.orders.empty? return o unless o.cores.any? do |core| core.projections.any? do |projection| - /DISTINCT.*FIRST_VALUE/ === projection + /FIRST_VALUE/ === projection end end # Previous version with join and split broke ORDER BY clause diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 4e1f7ab466..b61d5f7acd 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -90,7 +90,7 @@ module Arel warn(<<-eowarn) if $VERBOSE (#{caller.first}) Using UpdateManager without setting UpdateManager#key is deprecated and support will be removed in Arel 4.0.0. Please set the primary -key on UpdateManager using UpdateManager#key= +key on UpdateManager using UpdateManager#key= '#{key.inspect}' eowarn key = o.relation.primary_key end diff --git a/lib/arel/visitors/visitor.rb b/lib/arel/visitors/visitor.rb index 204657883f..420549b2aa 100644 --- a/lib/arel/visitors/visitor.rb +++ b/lib/arel/visitors/visitor.rb @@ -7,12 +7,15 @@ module Arel private - DISPATCH = Hash.new do |hash, klass| - hash[klass] = "visit_#{(klass.name || '').gsub('::', '_')}" + DISPATCH = Hash.new do |hash, visitor_class| + hash[visitor_class] = + Hash.new do |method_hash, node_class| + method_hash[node_class] = "visit_#{(node_class.name || '').gsub('::', '_')}" + end end def dispatch - DISPATCH + DISPATCH[self.class] end def visit object, attribute = nil |