Sha256: 6cae584784a866771f6be0a1e6a4177e582d6f982f33749a4aca9cab5503fc6f
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
module ActiveRecord module Core def initialize_dup(other) # :nodoc: @attributes = @attributes.dup # CPK # @attributes.reset(self.class.primary_key) Array(self.class.primary_key).each {|key| @attributes.reset(key)} run_callbacks(:initialize) unless _initialize_callbacks.empty? @aggregation_cache = {} @association_cache = {} @new_record = true @destroyed = false super end module ClassMethods def find(*ids) # :nodoc: # We don't have cache keys for this stuff yet return super unless ids.length == 1 return super if block_given? || primary_key.nil? || scope_attributes? || columns_hash.include?(inheritance_column) # CPK return super if self.composite? id = ids.first return super if StatementCache.unsupported_value?(id) key = primary_key statement = cached_find_by_statement(key) { |params| where(key => params.bind).limit(1) } record = statement.execute([id], connection).first unless record raise RecordNotFound.new("Couldn't find #{name} with '#{primary_key}'=#{id}", name, primary_key, id) end record rescue ::RangeError raise RecordNotFound.new("Couldn't find #{name} with an out of range value for '#{primary_key}'", name, primary_key) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
composite_primary_keys-11.0.0.rc2 | lib/composite_primary_keys/core.rb |