class Sequel::Qualifier

Handles qualifying existing datasets, so that unqualified columns in the dataset are qualified with a given table name.

Public Class Methods

new(ds, table) click to toggle source

Store the dataset to use as the basis for qualification, and the table used to qualify unqualified columns.

# File lib/sequel/ast_transformer.rb, line 86
def initialize(ds, table)
  @ds = ds
  @table = table
end

Private Instance Methods

v(o) click to toggle source

Turn SQL::Identifiers and symbols that aren't implicitly qualified into SQL::QualifiedIdentifiers. For symbols that are not implicitly qualified by are implicitly aliased, return an SQL::AliasedExpressions with a qualified version of the symbol.

Calls superclass method Sequel::ASTTransformer#v
# File lib/sequel/ast_transformer.rb, line 97
def v(o)
  case o
  when Symbol
    t, column, aliaz = @ds.send(:split_symbol, o)
    if t
      o
    elsif aliaz
      SQL::AliasedExpression.new(SQL::QualifiedIdentifier.new(@table, SQL::Identifier.new(column)), aliaz)
    else
      SQL::QualifiedIdentifier.new(@table, o)
    end
  when SQL::Identifier
    SQL::QualifiedIdentifier.new(@table, o)
  when SQL::QualifiedIdentifier, SQL::JoinClause
    # Return these directly, so we don't accidentally qualify symbols in them.
    o
  else
    super
  end
end