[Dbix-class] Updating part of a composite key

John Ramsden-Developer John.Ramsden2 at bbc.co.uk
Tue Mar 6 10:26:48 GMT 2007

I have a table 'broadcast', with a foreign key 'pid' to a table
and with primary key a composite of 'pid' and 'imi', i.e.:

  broadcast:                              version:

     pid  } broadcast  ----------->         pid  } version
     imi  }  key 0                                  key 0
       :::                                   :::

I want to write a test script that uses DBIx::Class to set up some
records, represented by $broadcast, $version_1, and $version_2,
such that initially $broadcast links to $version_1 and then is
changed by the following to link to $broadcast_2:


However, when I run the test it displays the following error
(referring to the line containing this call):

  Can't update Broadcast=HASH(0x2d72c14): row not found at

The SQL log showed that this call led to the following SQL:

  UPDATE broadcast SET pid = ?
   WHERE ( imi = ? AND pid = ? ): `pidhack_2', `imix002', `pidhack_2' 

In other words, it is using the required new key value in the WHERE
instead of the current key value i.e. obviously _should_ be (in this

  UPDATE broadcast SET pid = ?
   WHERE ( imi = ? AND pid = ? ): `pidhack_2', `imix002', `pidhack_1' 

Is there likely to be a problem with DBIx::Class updating parts of
Keys using the above?

Impressive though it is, I realize DBIx::Class it can't be infallible,
maybe in this situation it needs things spelled out more explicitly.

If so, can anyone suggest an alternative format for the above call,
or some extra information I need to include in the schema definition?

Thanks in advance.


John R Ramsden

This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.

More information about the Dbix-class mailing list