Method: Sequel::Dataset#first_source_alias
- Defined in:
- lib/sequel/dataset/misc.rb
#first_source_alias ⇒ Object
The first source (primary table) for this dataset. If the dataset doesn’t have a table, raises an Error. If the table is aliased, returns the aliased name.
DB[:table].first_source_alias
# => :table
DB[Sequel[:table].as(:t)].first_source_alias
# => :t
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/sequel/dataset/misc.rb', line 103 def first_source_alias source = @opts[:from] if source.nil? || source.empty? raise Error, 'No source specified for query' end case s = source.first when SQL::AliasedExpression s.alias when Symbol _, _, aliaz = split_symbol(s) aliaz ? aliaz.to_sym : s else s end end |