Sha256: dfd08eebbe5344199704f9fb441bc35f34e0af0d2a399fb0fbf08a83c1f6f530

Contents?: true

Size: 456 Bytes

Versions: 1

Compression:

Stored size: 456 Bytes

Contents

class Arel::Visitors::ToSql
  def column_for attr
    return unless attr
    name     = attr.name.to_s
    relation = attr.relation

    if has_columns_hash? relation
      relation.engine.columns_hash[name]
    elsif table_exists? relation.table_name
      column_cache(relation.table_name)[name]
    else
      nil
    end
  end

  def has_columns_hash?(relation)
    relation.respond_to?(:engine) && relation.engine.respond_to?(:columns_hash)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arel_columns_hash-0.1.0 lib/arel_columns_hash/to_sql.rb