diff options
author | Keenan Brock <keenan@thebrocks.net> | 2016-10-04 18:28:49 -0400 |
---|---|---|
committer | Keenan Brock <keenan@thebrocks.net> | 2017-12-05 09:36:08 -0500 |
commit | 2d78e3a160068d7a024e30b2178084d16cea9807 (patch) | |
tree | e8585cbdaabf61ca9466a25ef086425863191a4e /lib/arel | |
parent | 8f1db57f2d0f7d2cbb407f2c141dfd61ba8a599b (diff) | |
download | rails-2d78e3a160068d7a024e30b2178084d16cea9807.tar.gz rails-2d78e3a160068d7a024e30b2178084d16cea9807.tar.bz2 rails-2d78e3a160068d7a024e30b2178084d16cea9807.zip |
Introduce NodeExpression as parent of scalar nodes
SQL is very powerful. Many nodes can be used as a sub expression or
query. grouping all of these possible nodes together
Diffstat (limited to 'lib/arel')
-rw-r--r-- | lib/arel/nodes.rb | 1 | ||||
-rw-r--r-- | lib/arel/nodes/binary.rb | 2 | ||||
-rw-r--r-- | lib/arel/nodes/case.rb | 4 | ||||
-rw-r--r-- | lib/arel/nodes/casted.rb | 2 | ||||
-rw-r--r-- | lib/arel/nodes/extract.rb | 3 | ||||
-rw-r--r-- | lib/arel/nodes/false.rb | 2 | ||||
-rw-r--r-- | lib/arel/nodes/function.rb | 4 | ||||
-rw-r--r-- | lib/arel/nodes/grouping.rb | 1 | ||||
-rw-r--r-- | lib/arel/nodes/node_expression.rb | 11 | ||||
-rw-r--r-- | lib/arel/nodes/select_statement.rb | 2 | ||||
-rw-r--r-- | lib/arel/nodes/terminal.rb | 2 | ||||
-rw-r--r-- | lib/arel/nodes/true.rb | 2 | ||||
-rw-r--r-- | lib/arel/nodes/unary.rb | 2 | ||||
-rw-r--r-- | lib/arel/nodes/unary_operation.rb | 8 |
14 files changed, 21 insertions, 25 deletions
diff --git a/lib/arel/nodes.rb b/lib/arel/nodes.rb index bb8ad6500b..8c6572dd6a 100644 --- a/lib/arel/nodes.rb +++ b/lib/arel/nodes.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true # node require 'arel/nodes/node' +require 'arel/nodes/node_expression' require 'arel/nodes/select_statement' require 'arel/nodes/select_core' require 'arel/nodes/insert_statement' diff --git a/lib/arel/nodes/binary.rb b/lib/arel/nodes/binary.rb index 3001788774..a86d4e4696 100644 --- a/lib/arel/nodes/binary.rb +++ b/lib/arel/nodes/binary.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Arel module Nodes - class Binary < Arel::Nodes::Node + class Binary < Arel::Nodes::NodeExpression attr_accessor :left, :right def initialize left, right diff --git a/lib/arel/nodes/case.rb b/lib/arel/nodes/case.rb index 1edca40001..50ea1e0be2 100644 --- a/lib/arel/nodes/case.rb +++ b/lib/arel/nodes/case.rb @@ -2,10 +2,6 @@ module Arel module Nodes class Case < Arel::Nodes::Node - include Arel::OrderPredications - include Arel::Predications - include Arel::AliasPredication - attr_accessor :case, :conditions, :default def initialize expression = nil, default = nil diff --git a/lib/arel/nodes/casted.rb b/lib/arel/nodes/casted.rb index 1d7385d01b..f945063dd2 100644 --- a/lib/arel/nodes/casted.rb +++ b/lib/arel/nodes/casted.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Arel module Nodes - class Casted < Arel::Nodes::Node # :nodoc: + class Casted < Arel::Nodes::NodeExpression # :nodoc: attr_reader :val, :attribute def initialize val, attribute @val = val diff --git a/lib/arel/nodes/extract.rb b/lib/arel/nodes/extract.rb index 4e797b6770..fdf3004c6a 100644 --- a/lib/arel/nodes/extract.rb +++ b/lib/arel/nodes/extract.rb @@ -2,9 +2,6 @@ module Arel module Nodes class Extract < Arel::Nodes::Unary - include Arel::AliasPredication - include Arel::Predications - attr_accessor :field def initialize expr, field diff --git a/lib/arel/nodes/false.rb b/lib/arel/nodes/false.rb index fb821dd522..58132a2f90 100644 --- a/lib/arel/nodes/false.rb +++ b/lib/arel/nodes/false.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Arel module Nodes - class False < Arel::Nodes::Node + class False < Arel::Nodes::NodeExpression def hash self.class.hash end diff --git a/lib/arel/nodes/function.rb b/lib/arel/nodes/function.rb index b2b89ee9ff..b3bf8f3e51 100644 --- a/lib/arel/nodes/function.rb +++ b/lib/arel/nodes/function.rb @@ -1,10 +1,8 @@ # frozen_string_literal: true module Arel module Nodes - class Function < Arel::Nodes::Node - include Arel::Predications + class Function < Arel::Nodes::NodeExpression include Arel::WindowPredications - include Arel::OrderPredications attr_accessor :expressions, :alias, :distinct def initialize expr, aliaz = nil diff --git a/lib/arel/nodes/grouping.rb b/lib/arel/nodes/grouping.rb index 16911eb3b6..ffe66654ce 100644 --- a/lib/arel/nodes/grouping.rb +++ b/lib/arel/nodes/grouping.rb @@ -2,7 +2,6 @@ module Arel module Nodes class Grouping < Unary - include Arel::Predications end end end diff --git a/lib/arel/nodes/node_expression.rb b/lib/arel/nodes/node_expression.rb new file mode 100644 index 0000000000..c4d4c8f428 --- /dev/null +++ b/lib/arel/nodes/node_expression.rb @@ -0,0 +1,11 @@ +module Arel + module Nodes + class NodeExpression < Arel::Nodes::Node + include Arel::Expressions + include Arel::Predications + include Arel::AliasPredication + include Arel::OrderPredications + include Arel::Math + end + end +end diff --git a/lib/arel/nodes/select_statement.rb b/lib/arel/nodes/select_statement.rb index 641a08405d..79176d4be5 100644 --- a/lib/arel/nodes/select_statement.rb +++ b/lib/arel/nodes/select_statement.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Arel module Nodes - class SelectStatement < Arel::Nodes::Node + class SelectStatement < Arel::Nodes::NodeExpression attr_reader :cores attr_accessor :limit, :orders, :lock, :offset, :with diff --git a/lib/arel/nodes/terminal.rb b/lib/arel/nodes/terminal.rb index 421f039904..3a1cd7f0e1 100644 --- a/lib/arel/nodes/terminal.rb +++ b/lib/arel/nodes/terminal.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Arel module Nodes - class Distinct < Arel::Nodes::Node + class Distinct < Arel::Nodes::NodeExpression def hash self.class.hash end diff --git a/lib/arel/nodes/true.rb b/lib/arel/nodes/true.rb index bb9d8c1414..fdb8ed2095 100644 --- a/lib/arel/nodes/true.rb +++ b/lib/arel/nodes/true.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Arel module Nodes - class True < Arel::Nodes::Node + class True < Arel::Nodes::NodeExpression def hash self.class.hash end diff --git a/lib/arel/nodes/unary.rb b/lib/arel/nodes/unary.rb index a42744b1d5..5711d91dce 100644 --- a/lib/arel/nodes/unary.rb +++ b/lib/arel/nodes/unary.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Arel module Nodes - class Unary < Arel::Nodes::Node + class Unary < Arel::Nodes::NodeExpression attr_accessor :expr alias :value :expr diff --git a/lib/arel/nodes/unary_operation.rb b/lib/arel/nodes/unary_operation.rb index 3c56ef2026..be4e270e76 100644 --- a/lib/arel/nodes/unary_operation.rb +++ b/lib/arel/nodes/unary_operation.rb @@ -3,12 +3,6 @@ module Arel module Nodes class UnaryOperation < Unary - include Arel::Expressions - include Arel::Predications - include Arel::OrderPredications - include Arel::AliasPredication - include Arel::Math - attr_reader :operator def initialize operator, operand @@ -23,4 +17,4 @@ module Arel end end end -end
\ No newline at end of file +end |