[Bast-commits] r7858 - DBIx-Class/0.08/trunk/lib/DBIx/Class
frew at dev.catalyst.perl.org
frew at dev.catalyst.perl.org
Wed Nov 11 23:37:27 GMT 2009
Author: frew
Date: 2009-11-11 23:37:27 +0000 (Wed, 11 Nov 2009)
New Revision: 7858
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
Log:
some cleanup for $rs->populate
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm 2009-11-11 22:54:15 UTC (rev 7857)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm 2009-11-11 23:37:27 UTC (rev 7858)
@@ -1794,15 +1794,19 @@
}
return wantarray ? @created : \@created;
} else {
- my ($first, @rest) = @$data;
+ my $first = $data->[0];
- require overload;
- my @names = grep {
- (not ref $first->{$_}) || (ref $first->{$_} eq 'SCALAR') ||
- (overload::Method($first->{$_}, '""'))
- } keys %$first;
+ # if a column is a registered relationship, and is a non-blessed hash/array, consider
+ # it relationship data
+ my (@rels, @columns);
+ for (keys %$first) {
+ my $ref = ref $first->{$_};
+ $self->result_source->has_relationship($_) && ($ref eq 'ARRAY' or $ref eq 'HASH')
+ ? push @rels, $_
+ : push @columns, $_
+ ;
+ }
- my @rels = grep { $self->result_source->has_relationship($_) } keys %$first;
my @pks = $self->result_source->primary_columns;
## do the belongs_to relationships
@@ -1831,17 +1835,15 @@
delete $data->[$index]->{$rel};
$data->[$index] = {%{$data->[$index]}, %$related};
- push @names, keys %$related if $index == 0;
+ push @columns, keys %$related if $index == 0;
}
}
## do bulk insert on current row
- my @values = map { [ @$_{@names} ] } @$data;
-
$self->result_source->storage->insert_bulk(
$self->result_source,
- \@names,
- \@values,
+ \@columns,
+ [ map { [ @$_{@columns} ] } @$data ],
);
## do the has_many relationships
More information about the Bast-commits
mailing list