aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2017-06-15 00:18:16 -0400
committerGitHub <noreply@github.com>2017-06-15 00:18:16 -0400
commitf4840e1c76c25a9712a8e3db97aa0d7e209d4f23 (patch)
treeebdb1f34c5c06384fd0f2709b4238500ebf6c166 /activerecord/lib
parentf340490b98ac9f13f004b5db8863cb3ff6fb71f9 (diff)
parentf5f7ca57da2a486b4d2493cb70479174f2968ada (diff)
downloadrails-f4840e1c76c25a9712a8e3db97aa0d7e209d4f23.tar.gz
rails-f4840e1c76c25a9712a8e3db97aa0d7e209d4f23.tar.bz2
rails-f4840e1c76c25a9712a8e3db97aa0d7e209d4f23.zip
Merge pull request #29452 from kamipo/prevent_extra_sync_with_transaction_state
Prevent extra `sync_with_transaction_state`
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/attribute_methods/primary_key.rb7
1 files changed, 2 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/primary_key.rb b/activerecord/lib/active_record/attribute_methods/primary_key.rb
index b5fd0cb370..b9b2acff37 100644
--- a/activerecord/lib/active_record/attribute_methods/primary_key.rb
+++ b/activerecord/lib/active_record/attribute_methods/primary_key.rb
@@ -8,17 +8,14 @@ module ActiveRecord
# Returns this record's primary key value wrapped in an array if one is
# available.
def to_key
- sync_with_transaction_state
key = id
[key] if key
end
# Returns the primary key value.
def id
- if pk = self.class.primary_key
- sync_with_transaction_state
- _read_attribute(pk)
- end
+ sync_with_transaction_state
+ _read_attribute(self.class.primary_key) if self.class.primary_key
end
# Sets the primary key value.