Class: Symbol

Inherits:
Object show all
Includes:
Sequel::Postgres::ArrayOpMethods, Sequel::Postgres::HStoreOpMethods, Sequel::Postgres::InetOpMethods, Sequel::Postgres::JSONOpMethods, Sequel::Postgres::PGRowOp::ExpressionMethods, Sequel::Postgres::RangeOpMethods, Sequel::SQL::AliasMethods, Sequel::SQL::BooleanMethods, Sequel::SQL::CastMethods, Sequel::SQL::ComplexExpressionMethods, Sequel::SQL::InequalityMethods, Sequel::SQL::NumericMethods, Sequel::SQL::OrderMethods, Sequel::SQL::QualifyingMethods, Sequel::SQL::StringMethods, Sequel::SQL::SubscriptMethods
Defined in:
lib/sequel/extensions/core_extensions.rb,
lib/sequel/extensions/pg_row_ops.rb,
lib/sequel/extensions/pg_inet_ops.rb,
lib/sequel/extensions/pg_json_ops.rb,
lib/sequel/extensions/pg_array_ops.rb,
lib/sequel/extensions/pg_range_ops.rb,
lib/sequel/extensions/pg_hstore_ops.rb,
lib/sequel/extensions/ruby18_symbol_extensions.rb

Overview

Sequel extends Symbol to add methods to implement the SQL DSL.

Instance Method Summary collapse

Methods included from Sequel::SQL::ComplexExpressionMethods

#extract, #sql_boolean, #sql_number, #sql_string

Methods included from Sequel::SQL::SubscriptMethods

#sql_subscript

Methods included from Sequel::SQL::StringMethods

#ilike, #like

Methods included from Sequel::SQL::QualifyingMethods

#*, #qualify

Methods included from Sequel::SQL::NumericMethods

#+

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::Postgres::HStoreOpMethods

#hstore

Methods included from Sequel::Postgres::RangeOpMethods

#pg_range

Methods included from Sequel::Postgres::ArrayOpMethods

#pg_array

Methods included from Sequel::Postgres::JSONOpMethods

#pg_json, #pg_jsonb

Methods included from Sequel::Postgres::InetOpMethods

#pg_inet

Methods included from Sequel::Postgres::PGRowOp::ExpressionMethods

#pg_row

Instance Method Details

#[](*args) ⇒ Object

Create an SQL Function with the receiver as the function name and the given arguments.



19
20
21
# File 'lib/sequel/extensions/ruby18_symbol_extensions.rb', line 19

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

#identifierObject

Returns receiver wrapped in an Sequel::SQL::Identifier. Usually used to prevent splitting the symbol.

:a__b # SQL: "a"."b"
:a__b.identifier # SQL: "a__b"


215
216
217
# File 'lib/sequel/extensions/core_extensions.rb', line 215

def identifier
  Sequel::SQL::Identifier.new(self)
end

#sql_function(*args) ⇒ Object

Returns a Sequel::SQL::Function with this as the function name, and the given arguments. This is aliased as Symbol#[] if the RUBY_VERSION is less than 1.9.0. Ruby 1.9 defines Symbol#[], and Sequel doesn’t override methods defined by ruby itself.

:now.sql_function # SQL: now()
:sum.sql_function(:a) # SQL: sum(a)
:concat.sql_function(:a, :b) # SQL: concat(a, b)


227
228
229
# File 'lib/sequel/extensions/core_extensions.rb', line 227

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