module Sequel::ColumnsIntrospection

Public Instance Methods

columns() click to toggle source

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 28
def columns
  return @columns if @columns
  return columns_without_introspection unless cols = opts[:select] and !cols.empty?
  probable_columns = cols.map{|c| probable_column_name(c)}
  if probable_columns.all?
    @columns = probable_columns
  else
    columns_without_introspection
  end
end