Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit d4b6671cdb480d3c5f9b4b48fb9f9687217b9886 1 parent 11a92b3
Jeremy Kemper jeremy authored
2  activerecord/CHANGELOG
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]
4 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
View
@@ -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)
6 activerecord/test/finder_test.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.