I have a model which uses a composite primary key, one of whose
members is a column named "id" which is declared like this:
set_primary_keys :id, :sequence_id
That model is then declared to belong to a second model:
belongs_to :way, :foreign_key => :id
Loading the first model, and using :include to pull in the second one,
fails due to too many placeholders appearing in the SQL generated.
The reason is that composite_primary_keys is using record.send(k) to
obtain the values of the key components, but "id" is of course a
method that returns an array of all the key components rather than
fetching the actual field value. Changing the code to use
record.attributes[k] instead seems to fix the problem:
http://groups.google.com/group/compositekeys/web/cpk-belongs-to-id.patch
There are other places in the code which look like they are fetching
the key components the same way, so this might be a more widespread
problem?
Tom