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.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/sequel/extensions/dataset_source_alias.rb', line 46

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.



63
64
65
66
67
68
# File 'lib/sequel/extensions/dataset_source_alias.rb', line 63

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