CPK 0.6.2 - the “Santiago” release
Thanks to the fine work of Santiago on the forum, some sneaky defects have been found. The new release is now up on rubyforge and available via gem install composite_primary_keys.
Thanks to everyone for helping each other solve the “ActiveRecord hates Composite Primary Keys” legacy.
Bonus thought: Who wants to generate composite primary keys in their migrations?
Trackbacks
Use this link to trackback from your own site.






Dr. Nic, Thanks for all your hard work. And yes, I love migrations,so I’d use it for composite keys.
Our main machine here is an iSeries (AS/400). The database I want to try Rails out on contains…. composite keys! This is what I’ve been waiting for. I had just started learning rBatis, when I found out about your project. rBatis is flexible, but you lose the ability to use Rails relationships.
Now, I’m just waiting for the IBM DB2 adaptor/driver for iSeries…. Win/Linux etc. already supported by IBM.
I’m currently working on a sample Rails app using composite keys… might be nice to post a rails example for folks to get started with. I just grabbed the models from your tests as a start, and built the test data from sql… works good so far.
I’ll definitely post up the composite keys example on the cpk website when you’re done. I wrote an initial webpage (http://compositekeys.rubyforge.org) and Dave Thomas gave some very useful feedback. So refactoring it is the next priority so newcomers (who are probably also new to Rails/Ruby) can feel welcome and empowered.
Re iSeries drivers - if you feel bold, look through all the connection adapters in ActiveRecord gem and see if you can’t start to build the adapter you need. Prob one of them is a good starting place.
Thanks, I hacked away at the Ruby on Rails IBM DB2 adapter and got it to work with my iSeries (used existing ADO driver thru DBI)! Of course now my challenge is to modify your Composite_keys code to work with the iSeries DB2 dialect. There are two issues. First, DB2 doesn’t like quoting numerical values in sql. Second, the: Select (OrderID,LineID) in (’A45′,1) … doesn’t work in DB2.
p.s. Have you looked at rBatis (iBatis for Ruby) ( http://ibatis.apache.org/docs/ruby/ )? I got that to work with my iSeries driver, and it lets you write your own sql… lots of work, but then have flexiblity to
We may need to add per-adapter overrides for the sql generation. I was naive to assume that the SQL would be the same for all *SQL systems. On the forum, I’ve been solve an issue for SQL Server. That solution should be generic for other *SQL, and thus a general improvement.
This should also fix your 2nd problem. Check it out.
I’m not sure what you mean by quoting numerical items. Can you start a thread on the forum with an example?
http://groups.google.com/group/compositekeys