diff options
author | Matthew Draper <matthew@trebex.net> | 2018-04-25 08:18:02 +0930 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-25 08:18:02 +0930 |
commit | 989b1cb4a326632a686d61df42695b27e4ef6b2e (patch) | |
tree | 026a41714b44dba185f084f8f21bb81eb01db681 /activerecord/lib/arel/nodes/select_core.rb | |
parent | 7e815415edbe42f1df64d786a8f923a171778d64 (diff) | |
parent | 354f1c28e81d9846fb9e5346fcca50cf303c12c1 (diff) | |
download | rails-989b1cb4a326632a686d61df42695b27e4ef6b2e.tar.gz rails-989b1cb4a326632a686d61df42695b27e4ef6b2e.tar.bz2 rails-989b1cb4a326632a686d61df42695b27e4ef6b2e.zip |
Merge pull request #32097 from matthewd/arel
Merge Arel
Diffstat (limited to 'activerecord/lib/arel/nodes/select_core.rb')
-rw-r--r-- | activerecord/lib/arel/nodes/select_core.rb | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/activerecord/lib/arel/nodes/select_core.rb b/activerecord/lib/arel/nodes/select_core.rb new file mode 100644 index 0000000000..2defe61974 --- /dev/null +++ b/activerecord/lib/arel/nodes/select_core.rb @@ -0,0 +1,65 @@ +# frozen_string_literal: true + +module Arel # :nodoc: all + module Nodes + class SelectCore < Arel::Nodes::Node + attr_accessor :top, :projections, :wheres, :groups, :windows + attr_accessor :havings, :source, :set_quantifier + + def initialize + super() + @source = JoinSource.new nil + @top = nil + + # https://ronsavage.github.io/SQL/sql-92.bnf.html#set%20quantifier + @set_quantifier = nil + @projections = [] + @wheres = [] + @groups = [] + @havings = [] + @windows = [] + end + + def from + @source.left + end + + def from=(value) + @source.left = value + end + + alias :froms= :from= + alias :froms :from + + def initialize_copy(other) + super + @source = @source.clone if @source + @projections = @projections.clone + @wheres = @wheres.clone + @groups = @groups.clone + @havings = @havings.clone + @windows = @windows.clone + end + + def hash + [ + @source, @top, @set_quantifier, @projections, + @wheres, @groups, @havings, @windows + ].hash + end + + def eql?(other) + self.class == other.class && + self.source == other.source && + self.top == other.top && + self.set_quantifier == other.set_quantifier && + self.projections == other.projections && + self.wheres == other.wheres && + self.groups == other.groups && + self.havings == other.havings && + self.windows == other.windows + end + alias :== :eql? + end + end +end |