Attempt to guess the columns that will be returned if there are columns selected, in order to skip a database query to retrieve the columns. This should work with Symbols, SQL::Identifiers, SQL::QualifiedIdentifiers, and SQL::AliasedExpressions.
# File lib/sequel/extensions/columns_introspection.rb, line 20 20: def columns 21: return @columns if @columns 22: return columns_without_introspection unless cols = opts[:select] and !cols.empty? 23: probable_columns = cols.map{|c| probable_column_name(c)} 24: if probable_columns.all? 25: @columns = probable_columns 26: else 27: columns_without_introspection 28: end 29: end
Return the probable name of the column, or nil if one cannot be determined.
# File lib/sequel/extensions/columns_introspection.rb, line 35 35: def probable_column_name(c) 36: case c 37: when Symbol 38: _, c, a = split_symbol(c) 39: (a || c).to_sym 40: when SQL::Identifier 41: c.value.to_sym 42: when SQL::QualifiedIdentifier 43: col = c.column 44: col.is_a?(SQL::Identifier) ? col.value.to_sym : col.to_sym 45: when SQL::AliasedExpression 46: a = c.aliaz 47: a.is_a?(SQL::Identifier) ? a.value.to_sym : a.to_sym 48: end 49: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.