Class: Symbol

Instance Method Summary collapse

Methods included from Sequel::SQL::ComplexExpressionMethods

#extract, #sql_boolean, #sql_number, #sql_string

Methods included from Sequel::SQL::StringMethods

#ilike, #like

Methods included from Sequel::SQL::BooleanMethods

#~

Methods included from Sequel::SQL::OrderMethods

#asc, #desc

Methods included from Sequel::SQL::CastMethods

#cast, #cast_numeric, #cast_string

Methods included from Sequel::SQL::AliasMethods

#as

Methods included from Sequel::SQL::IdentifierMethods

#identifier

Methods included from Sequel::SQL::QualifyingMethods

#qualify

Instance Method Details

#*(ce = (arg=false;nil)) ⇒ Object

If no argument is given, returns a Sequel::SQL::ColumnAll object specifying all columns for this table. If an argument is given, returns a Sequel::SQL::NumericExpression using the * (multiplication) operator with this and the given argument.



178
179
180
181
# File 'lib/sequel_core/core_sql.rb', line 178

def *(ce=(arg=false;nil))
  return super(ce) unless arg == false
  Sequel::SQL::ColumnAll.new(self);
end

#sql_function(*args) ⇒ Object Also known as: []

Returns a Sequel::SQL::Function with this as the function name, and the given arguments. This is aliased as Symbol#[] if ruby 1.9 is not being used. ruby 1.9 includes Symbol#[], and Sequel doesn’t override methods defined by ruby itself.



187
188
189
# File 'lib/sequel_core/core_sql.rb', line 187

def sql_function(*args)
  Sequel::SQL::Function.new(self, *args)
end

#to_column_ref(ds) ⇒ Object

Delegate the creation of the resulting SQL to the given dataset, since it may be database dependent.



203
204
205
# File 'lib/sequel_core/core_sql.rb', line 203

def to_column_ref(ds)
  ds.symbol_to_column_ref(self)
end

#|(sub) ⇒ Object

If the given argument is an Integer or an array containing an Integer, returns a Sequel::SQL::Subscript with this column and the given arg. Otherwise returns a Sequel::SQL::BooleanExpression where this column (which should be boolean) or the given argument is true.



196
197
198
199
# File 'lib/sequel_core/core_sql.rb', line 196

def |(sub)
  return super unless (Integer === sub) || ((Array === sub) && sub.any?{|x| Integer === x})
  Sequel::SQL::Subscript.new(self, Array(sub))
end