X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Frelationship%2Fupdate_or_create_multi.t;h=59861268f86a48bce639afdac05312c4cd59915a;hb=c0329273268971824784f239f32c7246e68da9c5;hp=dd022a1694aa8eb2f3c2ca48a9d02c5ff424d588;hpb=8d005ad9929e4bf227919cb6374e2a9e9689324f;p=dbsrgits%2FDBIx-Class.git diff --git a/t/relationship/update_or_create_multi.t b/t/relationship/update_or_create_multi.t index dd022a1..5986126 100644 --- a/t/relationship/update_or_create_multi.t +++ b/t/relationship/update_or_create_multi.t @@ -1,15 +1,15 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } + use strict; use warnings; use Test::More; use Test::Exception; use Test::Warn; -use lib qw(t/lib); + use DBICTest; -use DBIC::SqlMakerTest; my $schema = DBICTest->init_schema(); -my $sdebug = $schema->storage->debug; my $artist = $schema->resultset ('Artist')->find(1); @@ -79,28 +79,30 @@ throws_ok { # expect a create, after a failed search using *only* the # *current* relationship and the unique column constraints # (so no year) -my @sql; -$schema->storage->debugcb(sub { push @sql, $_[1] }); -$schema->storage->debug (1); - -$genre->update_or_create_related ('cds', { - title => 'the best thing since vertical toasters', - artist => $artist, - year => 2012, -}); - -$schema->storage->debugcb(undef); -$schema->storage->debug ($sdebug); - -my ($search_sql) = $sql[0] =~ /^(SELECT .+?)\:/; -is_same_sql ( - $search_sql, - 'SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track - FROM cd me - WHERE ( me.artist = ? AND me.genreid = ? AND me.title = ? ) - ', - 'expected select issued', -); +$schema->is_executed_sql_bind( sub { + $genre->update_or_create_related ('cds', { + title => 'the best thing since vertical toasters', + artist => $artist, + year => 2012, + }); +}, [ + [ + 'SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track + FROM cd me + WHERE ( me.artist = ? AND me.genreid = ? AND me.title = ? ) + ', + 1, + 2, + "the best thing since vertical toasters", + ], + [ + 'INSERT INTO cd ( artist, genreid, title, year) VALUES ( ?, ?, ?, ? )', + 1, + 2, + "the best thing since vertical toasters", + 2012, + ], +], 'expected select issued' ); # a has_many search without a unique constraint makes no sense # but I am not sure what to test for - leaving open