aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/locking/optimistic.rb1
-rw-r--r--activerecord/lib/active_record/persistence.rb2
-rw-r--r--activerecord/test/cases/dirty_test.rb5
3 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb
index e1e24e2814..bf17f27e68 100644
--- a/activerecord/lib/active_record/locking/optimistic.rb
+++ b/activerecord/lib/active_record/locking/optimistic.rb
@@ -78,6 +78,7 @@ module ActiveRecord
end
def _update_record(attribute_names = self.attribute_names)
+ attribute_names &= self.class.column_names
return super unless locking_enabled?
return 0 if attribute_names.empty?
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 0b1000fcf9..4eecbd0629 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -703,7 +703,7 @@ module ActiveRecord
# Updates the associated record with values matching those of the instance attributes.
# Returns the number of affected rows.
- def _update_record(attribute_names = self.column_names)
+ def _update_record(attribute_names = self.attribute_names)
attribute_names &= self.class.column_names
attributes_values = arel_attributes_with_values_for_update(attribute_names)
if attributes_values.empty?
diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb
index d1a7366f5f..0791811d94 100644
--- a/activerecord/test/cases/dirty_test.rb
+++ b/activerecord/test/cases/dirty_test.rb
@@ -748,7 +748,10 @@ class DirtyTest < ActiveRecord::TestCase
record = klass.new(first_name: "Sean")
record.non_persisted_attribute_will_change!
- assert_predicate record, :non_persisted_attribute_changed?
+ assert record.save
+
+ record.non_persisted_attribute_will_change!
+
assert record.save
ensure
ActiveRecord::Base.partial_writes = original_partial_writes