rails/rails — pull request #11424 by kennyj (2013-07-13 18:10:38+00:00)
Title: Reset @column_defaults when assigning .

Reset @column_defaults when assigning `locking_column`.
We had a potential problem. For example:

```ruby
class Post < ActiveRecord::Base
self.column_defaults # if we call this unintentionally before setting locking_column ...
self.locking_column = 'my_locking_column'
end

Post.column_defaults["my_locking_column"]
=> nil # expected value is 0 !
```

The cause of this problem is @column_defaults caching.

```ruby
# activerecrd/lib/active_record/locking/optimistic.rb
def column_defaults
@column_defaults ||= begin
defaults = super

if defaults.key?(locking_column) && lock_optimistically
defaults[locking_column] ||= 0
end

defaults
end
end
```