rails/rails — pull request #12549 by makimoto (2013-10-15 19:39:38+00:00)
Title: Raise an exception when model without primary key calls .find_with_ids

I fixed exception handling for `.find` of models without primary key.

Now `.find` by models without primary key raises `StatementInvalid` exception by the invalid SQL query, but I think an exception should be raised before building a query.

```
irb(main):001:0> Post.find(1)
Post Load (0.3ms) SELECT `posts`.* FROM `posts` WHERE `posts`.`` = 1 LIMIT 1
Mysql2::Error: Unknown column 'posts.' in 'where clause': SELECT `posts`.* FROM `posts` WHERE `posts`.`` = 1 LIMIT 1
ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'posts.' in 'where clause': SELECT `posts`.* FROM `posts` WHERE `posts`.`` = 1 LIMIT 1
from /Users/makimoto/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/rails-dd37ff81d131/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:293:in `query'
```

By this PR `AR::UnknownPrimaryKey` are raised when `Model.primary_key` is `nil` and `Model.find` calls.

```
irb(main):001:0> Post.find(1)
ActiveRecord::UnknownPrimaryKey: Unknown primary key for table posts in model Post.
from /Users/makimoto/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/rails-dd37ff81d131/activerecord/lib/active_record/relation/finder_methods.rb:301:in `find_with_ids'
```