diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-04-01 15:04:11 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-04-01 15:04:11 +0900 |
commit | 6e43a207c6d3072d10b494d605b7bb6635043e30 (patch) | |
tree | b2c0ac655273cb2fedc556f62e8f902ed1e0d15c /activerecord/lib/arel | |
parent | 43866b2ca338375b964b0b905ee20f74f9b21b22 (diff) | |
download | rails-6e43a207c6d3072d10b494d605b7bb6635043e30.tar.gz rails-6e43a207c6d3072d10b494d605b7bb6635043e30.tar.bz2 rails-6e43a207c6d3072d10b494d605b7bb6635043e30.zip |
Revert unused code and re-using query annotation for `update_all` and `delete_all`
This partly reverts #35617.
#35617 includes unused code (for `InsertStatement`) and re-using query
annotation for `update_all` and `delete_all`, which has not been
discussed yet.
If a relation has any annotation, I think it is mostly for SELECT query,
so re-using annotation by default is not always desired behavior for me.
We should discuss about desired behavior before publishing the
implementation.
Diffstat (limited to 'activerecord/lib/arel')
-rw-r--r-- | activerecord/lib/arel/nodes/delete_statement.rb | 9 | ||||
-rw-r--r-- | activerecord/lib/arel/nodes/insert_statement.rb | 9 | ||||
-rw-r--r-- | activerecord/lib/arel/nodes/select_core.rb | 1 | ||||
-rw-r--r-- | activerecord/lib/arel/nodes/update_statement.rb | 9 | ||||
-rw-r--r-- | activerecord/lib/arel/select_manager.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/arel/tree_manager.rb | 5 | ||||
-rw-r--r-- | activerecord/lib/arel/visitors/to_sql.rb | 6 |
7 files changed, 11 insertions, 32 deletions
diff --git a/activerecord/lib/arel/nodes/delete_statement.rb b/activerecord/lib/arel/nodes/delete_statement.rb index 56249b2bad..a419975335 100644 --- a/activerecord/lib/arel/nodes/delete_statement.rb +++ b/activerecord/lib/arel/nodes/delete_statement.rb @@ -3,7 +3,7 @@ module Arel # :nodoc: all module Nodes class DeleteStatement < Arel::Nodes::Node - attr_accessor :left, :right, :orders, :limit, :offset, :key, :comment + attr_accessor :left, :right, :orders, :limit, :offset, :key alias :relation :left alias :relation= :left= @@ -18,18 +18,16 @@ module Arel # :nodoc: all @limit = nil @offset = nil @key = nil - @comment = nil end def initialize_copy(other) super @left = @left.clone if @left @right = @right.clone if @right - @comment = @comment.clone if @comment end def hash - [self.class, @left, @right, @orders, @limit, @offset, @key, @comment].hash + [self.class, @left, @right, @orders, @limit, @offset, @key].hash end def eql?(other) @@ -39,8 +37,7 @@ module Arel # :nodoc: all self.orders == other.orders && self.limit == other.limit && self.offset == other.offset && - self.key == other.key && - self.comment == other.comment + self.key == other.key end alias :== :eql? end diff --git a/activerecord/lib/arel/nodes/insert_statement.rb b/activerecord/lib/arel/nodes/insert_statement.rb index 8430dd23da..d28fd1f6c8 100644 --- a/activerecord/lib/arel/nodes/insert_statement.rb +++ b/activerecord/lib/arel/nodes/insert_statement.rb @@ -3,7 +3,7 @@ module Arel # :nodoc: all module Nodes class InsertStatement < Arel::Nodes::Node - attr_accessor :relation, :columns, :values, :select, :comment + attr_accessor :relation, :columns, :values, :select def initialize super() @@ -11,7 +11,6 @@ module Arel # :nodoc: all @columns = [] @values = nil @select = nil - @comment = nil end def initialize_copy(other) @@ -19,11 +18,10 @@ module Arel # :nodoc: all @columns = @columns.clone @values = @values.clone if @values @select = @select.clone if @select - @comment = @comment.clone if @comment end def hash - [@relation, @columns, @values, @select, @comment].hash + [@relation, @columns, @values, @select].hash end def eql?(other) @@ -31,8 +29,7 @@ module Arel # :nodoc: all self.relation == other.relation && self.columns == other.columns && self.select == other.select && - self.values == other.values && - self.comment == other.comment + self.values == other.values end alias :== :eql? end diff --git a/activerecord/lib/arel/nodes/select_core.rb b/activerecord/lib/arel/nodes/select_core.rb index b6154b7ff4..11b4f39ece 100644 --- a/activerecord/lib/arel/nodes/select_core.rb +++ b/activerecord/lib/arel/nodes/select_core.rb @@ -40,7 +40,6 @@ module Arel # :nodoc: all @groups = @groups.clone @havings = @havings.clone @windows = @windows.clone - @comment = @comment.clone if @comment end def hash diff --git a/activerecord/lib/arel/nodes/update_statement.rb b/activerecord/lib/arel/nodes/update_statement.rb index 015bcd7613..cfaa19e392 100644 --- a/activerecord/lib/arel/nodes/update_statement.rb +++ b/activerecord/lib/arel/nodes/update_statement.rb @@ -3,7 +3,7 @@ module Arel # :nodoc: all module Nodes class UpdateStatement < Arel::Nodes::Node - attr_accessor :relation, :wheres, :values, :orders, :limit, :offset, :key, :comment + attr_accessor :relation, :wheres, :values, :orders, :limit, :offset, :key def initialize @relation = nil @@ -13,18 +13,16 @@ module Arel # :nodoc: all @limit = nil @offset = nil @key = nil - @comment = nil end def initialize_copy(other) super @wheres = @wheres.clone @values = @values.clone - @comment = @comment.clone if @comment end def hash - [@relation, @wheres, @values, @orders, @limit, @offset, @key, @comment].hash + [@relation, @wheres, @values, @orders, @limit, @offset, @key].hash end def eql?(other) @@ -35,8 +33,7 @@ module Arel # :nodoc: all self.orders == other.orders && self.limit == other.limit && self.offset == other.offset && - self.key == other.key && - self.comment == other.comment + self.key == other.key end alias :== :eql? end diff --git a/activerecord/lib/arel/select_manager.rb b/activerecord/lib/arel/select_manager.rb index 4e9f527235..ddc9e394dd 100644 --- a/activerecord/lib/arel/select_manager.rb +++ b/activerecord/lib/arel/select_manager.rb @@ -249,10 +249,6 @@ module Arel # :nodoc: all self end - def comment_node - @ctx.comment - end - private def collapse(exprs) exprs = exprs.compact diff --git a/activerecord/lib/arel/tree_manager.rb b/activerecord/lib/arel/tree_manager.rb index 326c4f995c..0476399618 100644 --- a/activerecord/lib/arel/tree_manager.rb +++ b/activerecord/lib/arel/tree_manager.rb @@ -36,11 +36,6 @@ module Arel # :nodoc: all @ast.wheres << expr self end - - def comment(*values) - @ast.comment = Nodes::Comment.new(values) - self - end end attr_reader :ast diff --git a/activerecord/lib/arel/visitors/to_sql.rb b/activerecord/lib/arel/visitors/to_sql.rb index 4192d9efdc..277d553e6c 100644 --- a/activerecord/lib/arel/visitors/to_sql.rb +++ b/activerecord/lib/arel/visitors/to_sql.rb @@ -35,7 +35,6 @@ module Arel # :nodoc: all collect_nodes_for o.wheres, collector, " WHERE ", " AND " collect_nodes_for o.orders, collector, " ORDER BY " maybe_visit o.limit, collector - maybe_visit o.comment, collector end def visit_Arel_Nodes_UpdateStatement(o, collector) @@ -48,7 +47,6 @@ module Arel # :nodoc: all collect_nodes_for o.wheres, collector, " WHERE ", " AND " collect_nodes_for o.orders, collector, " ORDER BY " maybe_visit o.limit, collector - maybe_visit o.comment, collector end def visit_Arel_Nodes_InsertStatement(o, collector) @@ -64,9 +62,9 @@ module Arel # :nodoc: all maybe_visit o.values, collector elsif o.select maybe_visit o.select, collector + else + collector end - - maybe_visit o.comment, collector end def visit_Arel_Nodes_Exists(o, collector) |