Module: Sequel::Dataset::DatasetSourceAlias

Defined in:
lib/sequel/extensions/dataset_source_alias.rb

Instance Method Summary collapse

Instance Method Details

#from(*source, &block) ⇒ Object

Preprocess the list of sources and attempt to alias any datasets in the sources to the first source of the respective dataset.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/sequel/extensions/dataset_source_alias.rb', line 50

def from(*source, &block)
  virtual_row_columns(source, block)
  table_aliases = []
  source = source.map do |s|
    case s
    when Dataset
      s = dataset_source_alias_expression(s, table_aliases)
    when Symbol, String, SQL::AliasedExpression, SQL::Identifier, SQL::QualifiedIdentifier
      table_aliases << alias_symbol(s)
    end
    s
  end
  super(*source, &nil)
end

#join_table(type, table, expr = nil, options = OPTS) ⇒ Object

If a Dataset is given as the table argument, attempt to alias it to its source.



67
68
69
70
71
72
# File 'lib/sequel/extensions/dataset_source_alias.rb', line 67

def join_table(type, table, expr=nil, options=OPTS)
  if table.is_a?(Dataset) && !options[:table_alias]
    table = dataset_source_alias_expression(table)
  end
  super
end