Permalink
Browse files

Merge [6064] from trunk. References #6778.

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@6065 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 11a92b3 commit d4b6671cdb480d3c5f9b4b48fb9f9687217b9886 @jeremy jeremy committed Jan 28, 2007
View
@@ -1,5 +1,7 @@
*SVN*
+* MySQL: SET SQL_AUTO_IS_NULL=0 so 'where id is null' doesn't select the last inserted id. #6778 [Jonathan Viney, timc]
+
* Fixtures use the table name and connection from set_fixture_class. #7330 [Anthony Eden]
* SQLServer: quote table name in indexes query. #2928 [keithm@infused.org]
@@ -388,6 +388,10 @@ def connect
@connection.ssl_set(@config[:sslkey], @config[:sslcert], @config[:sslca], @config[:sslcapath], @config[:sslcipher]) if @config[:sslkey]
@connection.real_connect(*@connection_options)
execute("SET NAMES '#{encoding}'") if encoding
+
+ # By default, MySQL 'where id is null' selects the last inserted id.
+ # Turn this off. http://dev.rubyonrails.org/ticket/6778
+ execute("SET SQL_AUTO_IS_NULL=0")
end
def select(sql, name = nil)
@@ -450,6 +450,12 @@ def test_find_by_id_with_conditions_with_or
end
end
+ # http://dev.rubyonrails.org/ticket/6778
+ def test_find_ignores_previously_inserted_record
+ post = Post.create!
+ assert_equal [], Post.find_all_by_id(nil)
+ end
+
def test_find_by_empty_ids
assert_equal [], Post.find([])
end

0 comments on commit d4b6671

Please sign in to comment.