[Dbix-class] Bug(?) updating (multi) PKs

Matt S Trout dbix-class at trout.me.uk
Mon Dec 11 09:55:32 GMT 2006


On 11 Dec 2006, at 00:42, Paul Makepeace wrote:

> I have a schema: [publication <- publication_source -> source] and I'm
> trying to update the source_uid in the publication_source join table
> for a given publication. My strategy is to look for the row, if it
> exists update the source_uid, or create the join table row.
>
>    	my @ps = $publication->publication_source({ rank => $rank });
>  	if (@ps) {
>  		$ps[0]->source_uid($source_uid);
>  		$ps[0]->update;
>  	} else {
>  		$publication->add_to_publication_source({ rank => $rank,
> source_uid => $source_uid });
>  	}
>
> The problem comes that upon update the system attempts to identify
> which row to update using the *new* value of source_uid. Witness:
>
>       UPDATE publication_source SET source_uid = ? WHERE (
> publication_uid = ? AND rank = ? AND source_uid = ? ) (`282', `4355',
> `2', `282')
>
> So it's apparently not maintaining the old PK.

Correct. Scheduled to be fixed on -current before 08000

--  
Matt S Trout, Technical Director, Shadowcat Systems Ltd.
Offering custom development, consultancy and support contracts for  
Catalyst,
DBIx::Class and BAST. Contact mst (at) shadowcatsystems.co.uk for  
details.
+ Help us build a better perl ORM: http://dbix- 
class.shadowcatsystems.co.uk/ +





More information about the Dbix-class mailing list