Class: Sequel::SQL::VirtualRow
- Inherits:
- BasicObject
- Defined in:
- lib/sequel_core/sql.rb,
lib/sequel_core/sql.rb,
lib/sequel_core/sql.rb
Overview
An instance of this class is yielded to the block supplied to filter. Useful if another library also defines the operator methods that Sequel defines for symbols.
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')
Instance Method Summary collapse
-
#method_missing(m, *args) ⇒ Object
Can return Identifiers, QualifiedIdentifiers, or Functions:.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
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.
848 849 850 851 852 853 854 855 |
# File 'lib/sequel_core/sql.rb', line 848 def method_missing(m, *args) if args.empty? table, column = m.to_s.split('__', 2) column ? QualifiedIdentifier.new(table, column) : Identifier.new(m) else Function.new(m, *args) end end |