Class: Arel::SelectManager
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
TreeManager
|
|
Instance Chain:
|
|
Inherits: |
Arel::TreeManager
|
Defined in: | activerecord/lib/arel/select_manager.rb |
Constant Summary
-
STRING_OR_SYMBOL_CLASS =
# File 'activerecord/lib/arel/select_manager.rb', line 7[Symbol, String]
Class Method Summary
- .new(table = nil) ⇒ SelectManager constructor
Instance Attribute Summary
- #limit (also: #taken) rw
-
#limit=(limit)
rw
Alias for #take.
- #offset rw
-
#offset=(amount)
rw
Alias for #skip.
- #projections rw
- #projections=(projections) rw
TreeManager
- Inherited
Instance Method Summary
- #as(other)
- #comment(*values)
- #constraints
- #distinct(value = true)
- #distinct_on(value)
- #except(other) (also: #minus)
-
#exists
Produces an
Arel::Nodes::Exists
node. - #from(table)
- #froms
- #group(*columns)
- #having(expr)
- #initialize_copy(other)
- #intersect(other)
- #join(relation, klass = Nodes::InnerJoin)
- #join_sources
- #lateral(table_name = nil)
- #lock(locking = Arel.sql("FOR UPDATE"))
- #locked
-
#minus(other)
Alias for #except.
- #on(*exprs)
- #optimizer_hints(*hints)
- #order(*expr)
- #orders
- #outer_join(relation)
- #project(*projections)
- #skip(amount) (also: #offset=)
- #source
- #take(limit) (also: #limit=)
-
#taken
Alias for #limit.
- #union(operation, other = nil)
- #where(expr)
- #where_sql(engine = Table.engine)
- #window(name)
- #with(*subqueries)
- #collapse(exprs) private
Crud
- Included
TreeManager
- Inherited
FactoryMethods
- Included
#cast, #coalesce, #create_and, #create_false, #create_join, #create_on, #create_string_join, #create_table_alias, #create_true, #grouping, | |
#lower | Create a LOWER() function. |
Constructor Details
.new(table = nil) ⇒ SelectManager
# File 'activerecord/lib/arel/select_manager.rb', line 9
def initialize(table = nil) @ast = Nodes::SelectStatement.new(table) @ctx = @ast.cores.last end
Instance Attribute Details
#limit (rw) Also known as: #taken
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 19
def limit @ast.limit && @ast.limit.expr end
#limit=(limit) (rw)
Alias for #take.
# File 'activerecord/lib/arel/select_manager.rb', line 242
alias limit= take
#offset (rw)
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 28
def offset @ast.offset && @ast.offset.expr end
#offset=(amount) (rw)
Alias for #skip.
# File 'activerecord/lib/arel/select_manager.rb', line 40
alias :offset= :skip
#projections (rw)
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 139
def projections @ctx.projections end
#projections=(projections) (rw)
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 143
def projections=(projections) @ctx.projections = projections end
Instance Method Details
#as(other)
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 48
def as(other) create_table_alias grouping(@ast), Nodes::SqlLiteral.new(other, retryable: true) end
#collapse(exprs) (private)
[ GitHub ]#comment(*values)
[ GitHub ]#constraints
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 24
def constraints @ctx.wheres end
#distinct(value = true)
[ GitHub ]#distinct_on(value)
[ GitHub ]#except(other) Also known as: #minus
[ GitHub ]#exists
Produces an Arel::Nodes::Exists
node
#from(table)
[ GitHub ]#froms
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 98
def froms @ast.cores.filter_map { |x| x.from } end
#group(*columns)
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 74
def group(*columns) columns.each do |column| # FIXME: backwards compat column = Nodes::SqlLiteral.new(column) if String === column column = Nodes::SqlLiteral.new(column.to_s) if Symbol === column @ctx.groups.push Nodes::Group.new column end self end
#having(expr)
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 119
def having(expr) @ctx.havings << expr self end
#initialize_copy(other)
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 14
def initialize_copy(other) super @ctx = @ast.cores.last end
#intersect(other)
[ GitHub ]#join(relation, klass = Nodes::InnerJoin)
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 102
def join(relation, klass = Nodes::InnerJoin) return self unless relation case relation when String, Nodes::SqlLiteral raise EmptyJoinError if relation.empty? klass = Nodes::StringJoin end @ctx.source.right << create_join(relation, nil, klass) self end
#join_sources
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 244
def join_sources @ctx.source.right end
#lateral(table_name = nil)
[ GitHub ]#lock(locking = Arel.sql("FOR UPDATE"))
[ GitHub ]#locked
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 65
def locked @ast.lock end
#minus(other)
Alias for #except.
# File 'activerecord/lib/arel/select_manager.rb', line 216
alias :minus :except
#on(*exprs)
[ GitHub ]#optimizer_hints(*hints)
[ GitHub ]#order(*expr)
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 172
def order(*expr) # FIXME: We SHOULD NOT be converting these to SqlLiteral automatically @ast.orders.concat expr.map { |x| STRING_OR_SYMBOL_CLASS.include?(x.class) ? Nodes::SqlLiteral.new(x.to_s) : x } self end
#orders
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 180
def orders @ast.orders end
#outer_join(relation)
[ GitHub ]#project(*projections)
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 130
def project(*projections) # FIXME: converting these to SQLLiterals is probably not good, but # rails tests require it. @ctx.projections.concat projections.map { |x| STRING_OR_SYMBOL_CLASS.include?(x.class) ? Nodes::SqlLiteral.new(x.to_s) : x } self end
#skip(amount) Also known as: #offset=
[ GitHub ]#source
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 248
def source @ctx.source end
#take(limit) Also known as: #limit=
[ GitHub ]#taken
Alias for #limit.
# File 'activerecord/lib/arel/select_manager.rb', line 22
alias :taken :limit
#union(operation, other = nil)
[ GitHub ]#where(expr)
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 184
def where(expr) if Arel::TreeManager === expr expr = expr.ast end @ctx.wheres << expr self end
#where_sql(engine = Table.engine)
[ GitHub ]#window(name)
[ GitHub ]# File 'activerecord/lib/arel/select_manager.rb', line 124
def window(name) window = Nodes::NamedWindow.new(name) @ctx.windows.push window window end