aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorAlfred Wong <alfiewong@gmail.com>2012-06-17 11:43:31 -0400
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-07-24 13:18:21 -0300
commit33e1604b3e9d7c99f9e3b0988248acc46e626f34 (patch)
treeb0c67c4ab0afd054cb428b9338e4bcabc87117b6 /activerecord/lib
parentc4b93f57e1c29d6e1726d23d6ac2fdb75af9bdab (diff)
downloadrails-33e1604b3e9d7c99f9e3b0988248acc46e626f34.tar.gz
rails-33e1604b3e9d7c99f9e3b0988248acc46e626f34.tar.bz2
rails-33e1604b3e9d7c99f9e3b0988248acc46e626f34.zip
Specified column type for quote_value
When calling quote_value the underlying connection sometimes requires more information about the column to properly return the correct quoted value. I ran into this issue when using optimistic locking in JRuby and the activerecord-jdbcmssql-adapter. In SQLSever 2000, we aren't allowed to insert a integer into a NVARCHAR column type so we need to format it as N'3' if we want to insert into the NVARCHAR type. Unfortuantely, without the column type being passed the connection adapter cannot properly return the correct quote value because it doesn't know to return N'3' or '3'. This patch is fairly straight forward where it just passes in the column type into the quote_value, as it already has the ability to take in the column, so it can properly handle at the connection level. 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. Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/locking/optimistic.rb
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/locking/optimistic.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb
index b2881991d5..6265be8681 100644
--- a/activerecord/lib/active_record/locking/optimistic.rb
+++ b/activerecord/lib/active_record/locking/optimistic.rb
@@ -80,7 +80,7 @@ module ActiveRecord
stmt = relation.where(
relation.table[self.class.primary_key].eq(id).and(
- relation.table[lock_col].eq(quote_value(previous_lock_value))
+ relation.table[lock_col].eq(quote_value(previous_lock_value, self.class.columns_hash[lock_col]))
)
).arel.compile_update(arel_attributes_values(false, false, attribute_names))