[Rails-core] Composite primary key support in ActiveRecord?

Dae San Hwang daesan at gmail.com
Sat Feb 18 17:25:22 GMT 2006


Hi,

As I understand, composite primary keys aren't supported in  
ActiveRecord yet.  May I ask if there are plans for this feature?   
Better yet, if this feature is under development, how's the progress  
going?

I'm not trying to use legacy databases.  I tend to think that using  
multiple integer column id's (composite primary key) are often  
natural way to implement one-to-many relationships, for things like  
"forum replies".  For example, ID for the third comment of forum  
topic #87 should be (87, 3) not (87, 1074), format being (topic_id,  
reply_id).

Currently, I'm trying to work around this by using 'TopicReply.find 
(:fist, conditions => ["topic_id=? AND id=?", 87, 3]' instead of  
'TopicReply.find(1074)'.  However, I haven't figured out yet how to  
save such objects..

Any comment will be greatly appreciated.

Thanks,

daesan


More information about the Rails-core mailing list