mirror of https://github.com/rails/rails
Use _read_attribute(primary_key) instead of id
This will avoid the indirection of having calling id since we already know which is the primary key column. Also this will make explicit the behavior since it is not clear that id gets the right primary key value and not just the value of the "id" column.
This commit is contained in:
parent
9721b45b40
commit
b584cc68fc
|
@ -479,7 +479,7 @@ module ActiveRecord
|
|||
|
||||
clear_attribute_changes(changes.keys)
|
||||
primary_key = self.class.primary_key
|
||||
scope = self.class.unscoped.where(primary_key => id)
|
||||
scope = self.class.unscoped.where(primary_key => _read_attribute(primary_key))
|
||||
|
||||
if locking_enabled?
|
||||
locking_column = self.class.locking_column
|
||||
|
|
Loading…
Reference in New Issue