Method: Sequel::Dataset#split_alias

Defined in:
lib/sequel/dataset/misc.rb

#split_alias(c) ⇒ Object

Splits a possible implicit alias in c, handling both SQL::AliasedExpressions and Symbols. Returns an array of two elements, with the first being the main expression, and the second being the alias.


186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/sequel/dataset/misc.rb', line 186

def split_alias(c)
  case c
  when Symbol
    c_table, column, aliaz = split_symbol(c)
    [c_table ? SQL::QualifiedIdentifier.new(c_table, column.to_sym) : column.to_sym, aliaz]
  when SQL::AliasedExpression
    [c.expression, c.alias]
  when SQL::JoinClause
    [c.table, c.table_alias]
  else
    [c, nil]
  end
end