Fixed that pessimistic locking you reference the quoted table name (Josh...

Fixed that pessimistic locking you reference the quoted table name (Josh Susser) [#67 state:resolved]
上级 5cef8bcc
*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|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册