Browse files

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

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.
  • Loading branch information...
1 parent 2d6abcc commit 3e7a880903df0937faab1a9214870be3de260022 @alfredw committed Jun 17, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/locking/optimistic.rb
@@ -82,7 +82,7 @@ def update(attribute_names = @attributes.keys) #:nodoc:
stmt = relation.where(
- relation.table[lock_col].eq(self.class.quote_value(previous_lock_value))
+ relation.table[lock_col].eq(self.class.quote_value(previous_lock_value, self.class.columns_hash[lock_col]))

0 comments on commit 3e7a880

Please sign in to comment.