I've tested the below against the latest .08126 version, and it's still failing.
On 20 December 2010 13:32, Toby Corkindale <[email protected]> wrote: > See attached for an updated version of > t/relationship/update_or_create_single.t, which demonstrates the bug. > (Actually, attached both a patch against current version, and the > whole file, depending on which is easier for you to handle) > > This test fails against .08124 of DBIC. > > Toby > > On 16 December 2010 13:53, Toby Corkindale <[email protected]> wrote: >> I think I have found a bug in find_or_create(), although maybe it's >> more a case of "it should throw an error if you try this", instead of >> silenting doing the Wrong Thing. >> >> Viz: >> >> Assume you have these tables: >> table1, with columns "luser" and "role". >> The primary key is on "luser, role". >> "role" is a foreign key into table2.. >> >> table2 has columns "id" and "name". >> >> my $rs = $schema->resultset('table1'); >> $rs->find_or_create( >> { >> luser => 'john', >> role => { name => 'Admin' }, >> } >> ); >> >> In this case, the SELECT that dbix class does to try and find the user >> will be WHERE luser='john' AND role=NULL. >> >> When it then creates the row, it will correctly fill it in with the ID >> from the role table. >> Eg. like: >> INSERT INTO mytable (luser,role) >> VALUES ('john', (SELECT id FROM role WHERE name='Admin')); >> >> >> Umm.. Would you like me to try and make a (failing) test case for dbic for >> this? >> Or am I just being stupid.. It's more than possible :) >> >> Cheers, >> Toby > -- Turning and turning in the widening gyre The falcon cannot hear the falconer Things fall apart; the center cannot hold Mere anarchy is loosed upon the world _______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[email protected]
