rails/rails — pull request #5627 by arturopie (2012-03-28 02:32:11+00:00)
Title: Fixing Identity Map when using find select

## Issue:

When loading an object that doesn't contains all the columns (using 'select' for example), IdentityMap stores this partial object. If this object is used later, but in this case we want all the attributes (or at least one that wasn't loaded at the beginning), then we will get a 'MissingAttributeError'. The following code will fail, for example

```ruby
ActiveRecord::IdentityMap.use do
author = Author.select(:id).first
post = author.posts.first

name = post.author.name
end
```
However, this code will load the author's name from the db:

```ruby
author = Author.select(:id).first
post = author.posts.first

name = post.author.name
```

## Fix:

If the object being loaded doesn't contain all values for all its columns, then we don't save it in the repository of IdentityMap.

I also did some refactoring in base.rb

PS: Sorry for the number of commits, I will try to make fewer commits in a pull request next time. I can apply the cherry picks to the other branches if you accept this pull request.