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(table, unused=nil) click to toggle source

Set the table used to qualify unqualified columns

# File lib/sequel/ast_transformer.rb, line 93
def initialize(table, unused=nil)
  if unused
    # :nocov:
    Sequel::Deprecation.deprecate("Passing two arguments to Sequel::Qualifier.new", 'Pass only the second arguument specifying the table used for qualification')
    @table = unused
    # :nocov:
  else
    @table = table
  end
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 110
def v(o)
  case o
  when Symbol
    t, column, aliaz = Sequel.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