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) click to toggle source

Set the table used to qualify unqualified columns

   # File lib/sequel/ast_transformer.rb
93 def initialize(table)
94   @table = table
95 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
103 def v(o)
104   case o
105   when Symbol
106     t, column, aliaz = Sequel.split_symbol(o)
107     if t
108       o
109     elsif aliaz
110       SQL::AliasedExpression.new(SQL::QualifiedIdentifier.new(@table, SQL::Identifier.new(column)), aliaz)
111     else
112       SQL::QualifiedIdentifier.new(@table, o)
113     end
114   when SQL::Identifier
115     SQL::QualifiedIdentifier.new(@table, o)
116   when SQL::QualifiedIdentifier, SQL::JoinClause
117     # Return these directly, so we don't accidentally qualify symbols in them.
118     o
119   else
120     super
121   end
122 end