X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F100populate.t;h=d0427f13872a729305c03e190a58bb9aa457f003;hb=7c8e6d16ab3abbb889100f8236267f6682abecac;hp=94a97376ff973847674bfd577f0cf4a120c5a5b9;hpb=cbc3ee68a819d05e9dc9e7e34b6c5d4b661933bd;p=dbsrgits%2FDBIx-Class.git diff --git a/t/100populate.t b/t/100populate.t index 94a9737..d0427f1 100644 --- a/t/100populate.t +++ b/t/100populate.t @@ -445,19 +445,37 @@ lives_ok ( sub { ]) }, 'empty has_many relationship accepted by populate'); -done_testing; +lives_ok ( sub { + my $genre_max = $schema->resultset('Genre')->get_column('genreid')->max; + $schema->populate('CD', [ + {cdid => 10002, artist => $artist->id, title => 'Pretty Much Foo', year => 2011, genre => { name => 'country' } } + ]); + + is_deeply($schema->resultset('Genre')->search({ name => 'country' })->all_hri, + [{ genreid => $genre_max + 1, name => 'country' }], + "Populate() belongs_to inserts in void context" + ); +}, 'void context belongs_to rels are populated'); + +#my $q = $schema->resultset('CD')->search({}, { columns => [qw/artist year/], group_by => 'artist' })->as_query; +#$schema->storage->insert_bulk($artist_src, [qw/name rank/], [[[qw/foo 1/], [qw/baz 2/]], $q, [[qw/asdf 5/], [qw/uhiuh 6/]]]); +#my @cols = $artist_src->columns; my $artist_rs = $schema->resultset('Artist'); my $artist_src = $artist_rs->result_source; -my $q = $schema->resultset('CD')->search({}, { columns => [qw/artist year/], group_by => 'artist' })->as_query; +#use DDP::S; scope { my $count = 0; my $name = "zaaaaa"; +$artist_rs->populate([ + [qw/artistid name/], + [109, 'some crap'], + [110, 'some crap'], + sub { + return [$name++, ++$count] unless $count > 5; + return undef; + }, +]); +#}; -#$schema->storage->insert_bulk($artist_src, [qw/name rank/], [[[qw/foo 1/], [qw/baz 2/]], sub { -# return [$name++, ++$count] unless $count > 5; -# return undef; -#}, $q, [[qw/asdf 5/], [qw/uhiuh 6/]]]); - -my @cols = $artist_src->columns; -$rs->populate(\@cols, $rs->search(undef)->as_query ) +done_testing;