module Sequel::Dataset::DatasetSourceAlias
Public Instance Methods
Source
# File lib/sequel/extensions/dataset_source_alias.rb 50 def from(*source, &block) 51 virtual_row_columns(source, block) 52 table_aliases = [] 53 source = source.map do |s| 54 case s 55 when Dataset 56 s = dataset_source_alias_expression(s, table_aliases) 57 when Symbol, String, SQL::AliasedExpression, SQL::Identifier, SQL::QualifiedIdentifier 58 table_aliases << alias_symbol(s) 59 end 60 s 61 end 62 super(*source, &nil) 63 end
Preprocess the list of sources and attempt to alias any datasets in the sources to the first source of the respective dataset.
Calls superclass method
Source
# File lib/sequel/extensions/dataset_source_alias.rb 67 def join_table(type, table, expr=nil, options=OPTS) 68 if table.is_a?(Dataset) && !options[:table_alias] 69 table = dataset_source_alias_expression(table) 70 end 71 super 72 end
If a Dataset
is given as the table argument, attempt to alias it to its source.
Calls superclass method
Private Instance Methods
Source
# File lib/sequel/extensions/dataset_source_alias.rb 80 def dataset_source_alias_expression(ds, table_aliases=[]) 81 base = ds.first_source if ds.opts[:from] 82 case base 83 when Symbol, String, SQL::AliasedExpression, SQL::Identifier, SQL::QualifiedIdentifier 84 aliaz = unused_table_alias(base, table_aliases) 85 table_aliases << aliaz 86 ds.as(aliaz) 87 else 88 ds 89 end 90 end
Attempt to automatically alias the given dataset to its source. If the dataset cannot be automatically aliased to its source, return it unchanged. The table_aliases argument is a list of already used alias symbols, which will not be used as the alias.