Bug? find_by_id(nil) returns object just created

Tried to submit a ticket in Trac, but it reported an error…

Doing a Model.find_by_id(nil) after creating an object of type Model
returns
that object – and the next time, returns nil. It should always return
nil.

For example,
Step 1. Create an object:

Foo.create(:name => “bar”)
=> #<Foo:0x2aaaac3ade20 @new_record=false,
@errors=#<ActiveRecord::Errors:0x2aaaac3a8600 @base=#<Foo:0x2aaaac3ade20
…>, @errors={}>, @attributes={“name”=>“bar”, “id”=>7}>

Step 2. Use a dynamic finder with an id of nil:

Foo.find_by_id(nil)
=> #<Foo:0x2aaaac39dca0 @attributes={“name”=>“bar”, “id”=>“7”}>

Step: 3. Do the same find again:

Foo.find_by_id(nil)
=> nil

This only happens with any dynamic finder referencig ‘id’ (i.e.
find_by_id,
find_by_id_and_user_id, etc.), not with any other attribute.

I’m running Rails 1.1.4 on FC4, Mysql v. 4.1.14, Mysql-Ruby gem 2.7. It
was
replicated on Rails 1.1.1 on Debian stable, Mysql v. 4.1, Debian
libmysql-ruby1.8 vs. 2.4.5-6.1.

Have a feeling this came up a few weeks ago here, and that it was a
MySQL thing rather than AR. I seem to remember (though not 100%) the
story was that that MySQL returns the last record saved when finding by
nil(null)