}
for my $chunk (@chunked) {
- my $current = shift @$chunk;
-
- my $tuple;
- $tuple = sub {
- my $row = do {
- if (ref $current eq 'ARRAY') {
- shift @$current;
+ if (ref $chunk eq 'REF') {
+ $self->_insert_bulk($source, $cols, $chunk);
+ }
+ else {
+ my $current = shift @$chunk;
+
+ my $tuple;
+ $tuple = sub {
+ my $row = do {
+ if (ref $current eq 'ARRAY') {
+ shift @$current;
+ }
+ elsif (ref $current eq 'CODE') {
+ $current->();
+ }
+ };
+
+ if ($row) {
+ return $row;
}
- elsif (ref $current eq 'CODE') {
- $current->();
+ elsif (!defined $row && @$chunk) {
+ $current = shift @$chunk;
+ return $tuple->();
}
};
- if ($row) {
- return $row;
- }
- elsif (!defined $row && @$chunk) {
- $current = shift @$chunk;
- return $tuple->();
- }
- };
-
- $self->_insert_bulk($source, $cols, $tuple);
+ $self->_insert_bulk($source, $cols, $tuple);
+ }
}
}
else {
# we have a split codepath here where col validation happens in the
# fetch_tuple, but the tuple isnt used in no proto_bind situations, so we run it
- if (not @$proto_bind) {
+ if (!@$proto_bind && ref $data eq 'ARRAY') {
$data_filter->($data->[$_], $_) for (0..$#$data);
}
done_testing;
-my $q = $schema->resultset('Artist')
- ->search({
- },
- {
- columns => [qw/name rank/]
- })->as_query;
+my $q = $schema->resultset('Artist')->search({}, { columns => [qw/name rank/] })->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);
+$schema->storage->insert_bulk($schema->resultset('Artist')->result_source, [qw/name rank/], [$q]);