3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/sequel/fast_columns.rb', line 3
def columns
return @columns if @columns
@columns = if opts[:select]
if opts[:select].map(&:class).any? {|x| x == Sequel::LiteralString } ||
(opts[:join] && opts[:select].any? {|x| x == :* })
query_db_for_columns
else
opts[:select].map do |column|
case column
when Sequel::SQL::AliasedExpression
column.aliaz.to_sym
when Sequel::SQL::QualifiedIdentifier
column_name_from_symbol column.column
when Sequel::SQL::ColumnAll
get_all_columns(column.table)
when Symbol
column_name_from_symbol column
when Sequel::SQL::Expression
column.to_s(db).to_sym
else
column.to_s.to_sym
end
end.flatten
end
else
if opts[:join]
query_db_for_columns
else
get_all_columns opts[:from]
end
end
end
|