Class: ActiveRecord::Refined::AST::Quantified
- Includes:
- SetSubquery
- Defined in:
- lib/active_record/refined/ast.rb
Overview
ANY and ALL, which stand on the right of a comparison and say how many of the subquery's rows have to satisfy it. Where a scalar subquery has to return one row, these take as many as come.
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#relation ⇒ Object
readonly
Returns the value of attribute relation.
Instance Method Summary collapse
-
#initialize(kind, relation) ⇒ Quantified
constructor
A new instance of Quantified.
-
#to_arel(_table, _model) ⇒ Object
The subquery goes in as its own AST rather than as the manager, which would parenthesise it a second time -- and to PostgreSQL
ANY ((SELECT ...))is ANY of one scalar, which it refuses.
Methods inherited from Node
Constructor Details
#initialize(kind, relation) ⇒ Quantified
Returns a new instance of Quantified.
1242 1243 1244 1245 1246 1247 1248 1249 |
# File 'lib/active_record/refined/ast.rb', line 1242 def initialize(kind, relation) unless relation.is_a?(ActiveRecord::Relation) raise ArgumentError, "#{kind} takes a relation as its subquery; a list is what in? takes" end @kind = kind @relation = relation end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
1240 1241 1242 |
# File 'lib/active_record/refined/ast.rb', line 1240 def kind @kind end |
#relation ⇒ Object (readonly)
Returns the value of attribute relation.
1240 1241 1242 |
# File 'lib/active_record/refined/ast.rb', line 1240 def relation @relation end |
Instance Method Details
#to_arel(_table, _model) ⇒ Object
The subquery goes in as its own AST rather than as the manager,
which would parenthesise it a second time -- and to PostgreSQL
ANY ((SELECT ...)) is ANY of one scalar, which it refuses.
1254 1255 1256 |
# File 'lib/active_record/refined/ast.rb', line 1254 def to_arel(_table, _model) Arel::Nodes::NamedFunction.new(kind, [set_subquery(relation, kind).ast]) end |