Class | Sequel::SQL::VirtualRow |
In: |
lib/sequel/sql.rb
|
Parent: | BasicObject |
The purpose of this class is to allow the easy creation of SQL identifiers and functions without relying on methods defined on Symbol. This is useful if another library defines the methods defined by Sequel, or if you are running on ruby 1.9.
An instance of this class is yielded to the block supplied to filter, order, and select. If Sequel.virtual_row_instance_eval is true and the block doesn‘t take an argument, the block is instance_evaled in the context of a new instance of this class.
Examples:
ds = DB[:t] ds.filter{|r| r.name < 2} # SELECT * FROM t WHERE (name < 2) ds.filter{|r| r.table__column + 1 < 2} # SELECT * FROM t WHERE ((table.column + 1) < 2) ds.filter{|r| r.is_active(1, 'arg2')} # SELECT * FROM t WHERE is_active(1, 'arg2')
Can return Identifiers, QualifiedIdentifiers, or Functions:
# File lib/sequel/sql.rb, line 771 771: def method_missing(m, *args) 772: if args.empty? 773: table, column = m.to_s.split('__', 2) 774: column ? QualifiedIdentifier.new(table, column) : Identifier.new(m) 775: else 776: Function.new(m, *args) 777: end 778: end