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')

### Methods

method_missing

### Public Instance methods

method_missing(m, *args)

Can return Identifiers, QualifiedIdentifiers, or Functions:

- Function - returned if any arguments are supplied, using the method name as the function name, and the arguments as the function arguments.
- QualifiedIdentifier - returned if the method name contains __, with the table being the part before __, and the column being the part after.
- Identifier - returned otherwise, using the method name.

[Source]

         # File lib/sequel/sql.rb, line 773
    773:       def method_missing(m, *args)
    774:         if args.empty?
    775:           table, column = m.to_s.split('__', 2)
    776:           column ? QualifiedIdentifier.new(table, column) : Identifier.new(m)
    777:         else
    778:           Function.new(m, *args)
    779:         end
    780:       end

[Validate]