Permalink
Browse files

Fixed that pessimistic locking you reference the quoted table name (J…

…osh Susser) [#67 state:resolved]
  • Loading branch information...
1 parent 5cef8bc commit c353794dff580c8aa63b357b2857c1fadff3104b @dhh dhh committed Apr 30, 2008
View
@@ -1,5 +1,7 @@
*SVN*
+* Fixed that pessimistic locking you reference the quoted table name (Josh Susser) [#67]
+
* Fixed that change_column should be able to use :null => true on a field that formerly had false [Nate Wiger] [#26]
* Added that the MySQL adapter should map integer to either smallint, int, or bigint depending on the :limit just like PostgreSQL [DHH]
@@ -78,7 +78,7 @@ def update_with_lock(attribute_names = @attributes.keys) #:nodoc:
begin
affected_rows = connection.update(<<-end_sql, "#{self.class.name} Update with optimistic locking")
- UPDATE #{self.class.table_name}
+ UPDATE #{self.class.quoted_table_name}
SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false, false, attribute_names))}
WHERE #{self.class.primary_key} = #{quote_value(id)}
AND #{self.class.quoted_locking_column} = #{quote_value(previous_value)}
@@ -2,6 +2,7 @@
require 'models/person'
require 'models/reader'
require 'models/legacy_thing'
+require 'models/reference'
class LockWithoutDefault < ActiveRecord::Base; end
@@ -15,7 +16,7 @@ class ReadonlyFirstNamePerson < Person
end
class OptimisticLockingTest < ActiveRecord::TestCase
- fixtures :people, :legacy_things
+ fixtures :people, :legacy_things, :references
# need to disable transactional fixtures, because otherwise the sqlite3
# adapter (at least) chokes when we try and change the schema in the middle
@@ -138,6 +139,12 @@ def test_readonly_attributes
end
end
end
+
+ def test_quote_table_name
+ ref = references(:michael_magician)
+ ref.favourite = !ref.favourite
+ assert ref.save
+ end
private
@@ -206,6 +206,7 @@ def create_table(*args, &block)
t.integer :person_id
t.integer :job_id
t.boolean :favourite
+ t.integer :lock_version, :default => 0
end
create_table :minimalistics, :force => true do |t|

0 comments on commit c353794

Please sign in to comment.