Module: Sequel::SQL::QualifyingMethods

Included in:
Identifier, QualifiedIdentifier, Symbol
Defined in:
lib/sequel/sql.rb

Overview

Includes a qualify and [] methods that create QualifiedIdentifiers, used for qualifying column names with a table or table names with a schema, and the * method for returning all columns in the identifier if no arguments are given.

Instance Method Summary collapse

Instance Method Details

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

If no arguments are given, return an SQL::ColumnAll:

Sequel[:a].*  # a.*

897
898
899
900
901
902
903
# File 'lib/sequel/sql.rb', line 897

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

#[](identifier) ⇒ Object

Qualify the receiver with the given qualifier (table for column/schema for table).

Sequel[:table][:column]          # "table"."column"
Sequel[:schema][:table]          # "schema"."table"
Sequel[:schema][:table][:column] # "schema"."table"."column"

919
920
921
# File 'lib/sequel/sql.rb', line 919

def [](identifier)
  QualifiedIdentifier.new(self, identifier)
end

#qualify(qualifier) ⇒ Object

Qualify the receiver with the given qualifier (table for column/schema for table).

Sequel[:column].qualify(:table)                  # "table"."column"
Sequel[:table].qualify(:schema)                  # "schema"."table"
Sequel.qualify(:table, :column).qualify(:schema) # "schema"."table"."column"

910
911
912
# File 'lib/sequel/sql.rb', line 910

def qualify(qualifier)
  QualifiedIdentifier.new(qualifier, self)
end