[Dbix-class] Relations on non in_storage rows (my todays gotcha)

Zbigniew Lukasiak zzbbyy at gmail.com
Sun May 11 11:06:54 BST 2008


If you have a new object, not yet in the database, like:

$new_cd = $schema->resultset("CD")->new( {} );

Then if you call $new_cd->artist - this will return a first artist in
the 'artist' table.

So when writing code where you receive a DBIC row - and you don't know
where it comes from - you need to be carefull when calling relations
on it.

I wonder if this could be fixed by just returning 'undef' for 'single'
(and 'filtered'?) relations and '()' for 'multi' relations by the row
in such calls.

-- 
Zbigniew Lukasiak
http://brudnopis.blogspot.com/



More information about the DBIx-Class mailing list