logo       

Updating part of a composite key: msg#00019

Subject: Updating part of a composite key
I have a table 'broadcast', with a foreign key 'pid' to a table
'version',
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:

  $broadcast->version($version_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
t/unit/misc/hack.t

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
clause,
instead of the current key value i.e. obviously _should_ be (in this
case):

  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
composite
Keys using the above?

Impressive though it is, I realize DBIx::Class it can't be infallible,
and
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.


Cheers

John R Ramsden

http://www.bbc.co.uk/
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.
                                        



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe