From: Matt Phillips Date: Fri, 17 May 2013 20:38:32 +0000 (-0400) Subject: squash, bug in grouper X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=commitdiff_plain;h=e2f9f7ba9281d33526b5da5c449650e9f9e40c22 squash, bug in grouper --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index f7e6222..4986a55 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1983,7 +1983,7 @@ sub insert_bulk { for my $datum (@$data) { if ((ref $datum eq 'ARRAY' && ref $datum->[0] eq 'ARRAY') || ref $datum eq 'CODE') { - $chunked[-1] ||= []; + push @chunked, [] if ref $chunked[-1] ne 'ARRAY'; push @{$chunked[-1]}, $datum; } elsif (ref $datum eq 'REF') { diff --git a/t/100populate.t b/t/100populate.t index 7f824f2..378c398 100644 --- a/t/100populate.t +++ b/t/100populate.t @@ -447,9 +447,14 @@ lives_ok ( sub { done_testing; -my $q = $schema->resultset('Artist')->search({}, { columns => [qw/name rank/] })->as_query; +my $q = $schema->resultset('CD')->search({}, { columns => [qw/artist year/], group_by => 'artist' })->as_query; #p $q; #diag Dumper($q); #p $schema->resultset('Artist')->result_source; #p Dumper $q; -$schema->storage->insert_bulk($schema->resultset('Artist')->result_source, [qw/name rank/], [$q]); +my $count = 0; +my $name = "zaaaaa"; +$schema->storage->insert_bulk($schema->resultset('Artist')->result_source, [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/]]]);