From c083dc22dd16c3c2e43bbe1e13e4ee210c2adbc1 Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Sat, 20 Jul 2013 20:15:48 -0700 Subject: Tidy up the "Specified column type for quote_value" changes This includes fixing typos in changelog, removing a deprecated mocha/setup test require, and preferring the `column_for_attribute` accessor over direct access to the columns_hash in the new code. --- activerecord/CHANGELOG.md | 5 +++-- activerecord/lib/active_record/locking/optimistic.rb | 2 +- activerecord/test/cases/locking_test.rb | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'activerecord') diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 8ab9a64244..76174dc398 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,7 +1,8 @@ -* When using optimisitc locking, `update` whas not passing the column type to `quote_value` +* When using optimistic locking, `update` was not passing the column to `quote_value` to allow the connection adapter to properly determine how to quote the value. This was affecting certain databases that use specific colmn types. - Fix #6763 + + Fixes: #6763 *Alfred Wong* diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb index a1501ee453..626fe40103 100644 --- a/activerecord/lib/active_record/locking/optimistic.rb +++ b/activerecord/lib/active_record/locking/optimistic.rb @@ -82,7 +82,7 @@ module ActiveRecord stmt = relation.where( relation.table[self.class.primary_key].eq(id).and( - relation.table[lock_col].eq(self.class.quote_value(previous_lock_value, self.class.columns_hash[lock_col])) + relation.table[lock_col].eq(self.class.quote_value(previous_lock_value, column_for_attribute(lock_col))) ) ).arel.compile_update(arel_attributes_with_values_for_update(attribute_names)) diff --git a/activerecord/test/cases/locking_test.rb b/activerecord/test/cases/locking_test.rb index 4a72b69848..dfa12cb97c 100644 --- a/activerecord/test/cases/locking_test.rb +++ b/activerecord/test/cases/locking_test.rb @@ -1,5 +1,4 @@ require 'thread' -require 'mocha/setup' require "cases/helper" require 'models/person' require 'models/job' -- cgit v1.2.3