X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F100populate.t;h=c2c94918f7591434f16760afab219651005790b8;hb=a9e8284f478f029f6f50c9423c3fa20aa3256d4a;hp=52374805c6eae782b25ff1a61aae11f62a725dcb;hpb=18d80024c95f440cf8a7600f4340ef5247c6b15a;p=dbsrgits%2FDBIx-Class.git diff --git a/t/100populate.t b/t/100populate.t index 5237480..c2c9491 100644 --- a/t/100populate.t +++ b/t/100populate.t @@ -115,47 +115,46 @@ is($link7->id, 7, 'Link 7 id'); is($link7->url, undef, 'Link 7 url'); is($link7->title, 'gtitle', 'Link 7 title'); -my $rs = $schema->resultset('Artist'); -$rs->delete; +# populate with literals +{ + my $rs = $schema->resultset('Link'); + $rs->delete; -# test _execute_array_empty (insert_bulk with all literal sql) + # test _execute_array_empty (insert_bulk with all literal sql) -$rs->populate([ + $rs->populate([ (+{ - name => \"'DT'", - rank => \500, - charfield => \"'mtfnpy'", + url => \"'cpan.org'", + title => \"'The ''best of'' cpan'", }) x 5 -]); + ]); -is((grep { - $_->name eq 'DT' && - $_->rank == 500 && - $_->charfield eq 'mtfnpy' -} $rs->all), 5, 'populate with all literal SQL'); + is((grep { + $_->url eq 'cpan.org' && + $_->title eq "The 'best of' cpan", + } $rs->all), 5, 'populate with all literal SQL'); -$rs->delete; + $rs->delete; -# test mixed binds with literal sql + # test mixed binds with literal sql -$rs->populate([ + $rs->populate([ (+{ - name => \"'DT'", - rank => 500, - charfield => \"'mtfnpy'", + url => \"'cpan.org'", + title => "The 'best of' cpan", }) x 5 -]); - -is((grep { - $_->name eq 'DT' && - $_->rank == 500 && - $_->charfield eq 'mtfnpy' -} $rs->all), 5, 'populate with all literal SQL'); + ]); -$rs->delete; + is((grep { + $_->url eq 'cpan.org' && + $_->title eq "The 'best of' cpan", + } $rs->all), 5, 'populate with all literal SQL'); -### + $rs->delete; +} +my $rs = $schema->resultset('Artist'); +$rs->delete; throws_ok { $rs->populate([ { @@ -314,6 +313,12 @@ lives_ok { autopilot => 'b', }] }]) -} 'fix RT50828'; +} 'multicol-PK has_many populate works'; + +lives_ok ( sub { + $schema->populate('CD', [ + {cdid => 10001, artist => $artist->id, title => 'Pretty Much Empty', year => 2011, tracks => []}, + ]) +}, 'empty has_many relationship accepted by populate'); done_testing;