mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
id_in_database
do not return nil value for persisted record
This removes `|| id` which were added in #9963 and #23887 since it is no longer necessary.
This commit is contained in:
parent
7d5a7b30cc
commit
6932998fc7
2 changed files with 4 additions and 4 deletions
|
@ -188,8 +188,8 @@ module ActiveRecord
|
|||
connection.insert(im, "#{self} Create", primary_key || false, primary_key_value)
|
||||
end
|
||||
|
||||
def _update_record(values, id, id_was) # :nodoc:
|
||||
bind = predicate_builder.build_bind_attribute(primary_key, id_was || id)
|
||||
def _update_record(values, id) # :nodoc:
|
||||
bind = predicate_builder.build_bind_attribute(primary_key, id)
|
||||
um = arel_table.where(
|
||||
arel_attribute(primary_key).eq(bind)
|
||||
).compile_update(_substitute_values(values), primary_key)
|
||||
|
@ -710,7 +710,7 @@ module ActiveRecord
|
|||
rows_affected = 0
|
||||
@_trigger_update_callback = true
|
||||
else
|
||||
rows_affected = self.class._update_record(attributes_values, id, id_in_database)
|
||||
rows_affected = self.class._update_record(attributes_values, id_in_database)
|
||||
@_trigger_update_callback = rows_affected > 0
|
||||
end
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ module ActiveRecord
|
|||
relation = build_relation(finder_class, attribute, value)
|
||||
if record.persisted?
|
||||
if finder_class.primary_key
|
||||
relation = relation.where.not(finder_class.primary_key => record.id_in_database || record.id)
|
||||
relation = relation.where.not(finder_class.primary_key => record.id_in_database)
|
||||
else
|
||||
raise UnknownPrimaryKey.new(finder_class, "Can not validate uniqueness for persisted record without primary key.")
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue