Skip to content

Commit

Permalink
Added tests for optimistic lock update method
Browse files Browse the repository at this point in the history
I've added the tests required to make sure that the quote_value method
is being passed the column type so that the underlying connection can
determine how to quote the value.
  • Loading branch information
alfredw committed Dec 16, 2012
1 parent 7510cd6 commit dd51a39
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions activerecord/CHANGELOG.md
@@ -1,5 +1,12 @@
## Rails 4.0.0 (unreleased) ##

* When using optimisitc locking, `update` whas not passing the column type 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

*Alfred Wong*

* Do not log the binding values for binary columns.

*Matthew M. Boedicker*
Expand Down
13 changes: 13 additions & 0 deletions activerecord/test/cases/locking_test.rb
@@ -1,4 +1,5 @@
require 'thread'
require 'mocha/setup'
require "cases/helper"
require 'models/person'
require 'models/job'
Expand Down Expand Up @@ -26,6 +27,18 @@ class ReadonlyNameShip < Ship
class OptimisticLockingTest < ActiveRecord::TestCase
fixtures :people, :legacy_things, :references, :string_key_objects, :peoples_treasures

def test_quote_value_passed_lock_col
p1 = Person.find(1)
assert_equal 0, p1.lock_version

Person.expects(:quote_value).with(0, Person.columns_hash[Person.locking_column]).returns('0').once

p1.first_name = 'anika2'
p1.save!

assert_equal 1, p1.lock_version
end

def test_non_integer_lock_existing
s1 = StringKeyObject.find("record1")
s2 = StringKeyObject.find("record1")
Expand Down

0 comments on commit dd51a39

Please sign in to comment.