Module: ActiveRecord::FinderMethods

Defined in:
lib/active_record/connection_adapters/rubyfb_adapter.rb

Overview

FIXME ugly - but … github.com/rails/rails/issues/1623

Instance Method Summary collapse

Instance Method Details

#exists?(id = nil) ⇒ Boolean

Returns:

  • (Boolean)

78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/active_record/connection_adapters/rubyfb_adapter.rb', line 78

def exists?(id = nil)
  return rubyfb_exists_save(id) unless ActiveRecord::VERSION::MAJOR >= 3 && (ActiveRecord::VERSION::MINOR > 0 || ActiveRecord::VERSION::TINY >= 9)

  id = id.id if ActiveRecord::Base === id

  join_dependency = construct_join_dependency_for_association_find
  relation = construct_relation_for_association_find(join_dependency)
  relation = relation.except(:select).select("1 as o").limit(1)

  case id
  when Array, Hash
    relation = relation.where(id)
  else
    relation = relation.where(table[primary_key].eq(id)) if id
  end

  connection.select_value(relation.to_sql) ? true : false
end

#rubyfb_exists_saveObject


77
# File 'lib/active_record/connection_adapters/rubyfb_adapter.rb', line 77

alias :rubyfb_exists_save :exists?