Mysql error when no id column

Hi,

I've got some information in a new table I'm adding to my system. (I'm not a database person, so forgive my lack of correct terminology.) I was expecting to access the table via fields other than the id field (contribution_id, user_id and/or ip_address), but never by id, so I didn't create the table with the id field (":id => false" in my create_table call.

Anyway, it seemed to work find for creating records. But when I went to modify an object and save it, I got the following error:

Mysql::Error: #42S22Unknown column 'id' in 'where clause': UPDATE ratings SET `contribution_id` = 27, `user_id` = NULL, `rate_good` = 0, `ip_address` = '127.0.0.1' WHERE id = NULL

Now if I change my table definition to have an id field (ie, get rid of the ":id => false" clause), everything seems to work fine.

Does this sound like a bug, or user-error? If the latter, what am I misunderstanding and what is the fix?

Thanks, Brad

Active record just really really wants you to have a primary key (which you don't have to call id)

Then why would create_table have an ":id => *boolean*" parameter?

Should :id be deprecated?

Brad

because by default, the create table will create an "id" field all by itself. So, you have to set that parameter to 'false' if you do not want that id field to be created (in which case, you will be required to put in a field that serves as the primary key if you want one)

hope this helps, Cheers Mohit.

If that were the case, then wouldn't the assignment of the alternative primary key field be a sufficient indicator for the primary key alternative?

Brad