X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSet.pm;h=fcbbcc1feaac9ae7a4d718d44f33b9f0357ef53a;hb=7c8e6d16ab3abbb889100f8236267f6682abecac;hp=d0e500681a1026ae95cddc4d2f8e0f768c39fa37;hpb=cbc3ee68a819d05e9dc9e7e34b6c5d4b661933bd;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index d0e5006..fcbbcc1 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -2241,6 +2241,7 @@ sub populate { my $data = $self->_normalize_populate_to_arrayref(@_); return unless @$data; + use DDP; p $data; my $first = shift @$data; @@ -2249,14 +2250,20 @@ sub populate { my (@rels, @columns); my $rsrc = $self->result_source; my $rels = { map { $_ => $rsrc->relationship_info($_) } $rsrc->relationships }; - for my $index (0..$#$first) { - my $col = $first->[$index]; - my $val = $data->[0][$index]; - my $ref = ref $val; - $rels->{$col} && ($ref eq 'ARRAY' or $ref eq 'HASH') - ? push @rels, $col - : push @columns, $col - ; + + if (ref $data->[0] eq 'CODE') { + @columns = @$first; + } + else { + for my $index (0..$#$first) { + my $col = $first->[$index]; + my $val = $data->[0][$index]; + my $ref = ref $val; + $rels->{$col} && ($ref eq 'ARRAY' or $ref eq 'HASH') + ? push @rels, $col + : push @columns, $col + ; + } } my @pks = $rsrc->primary_columns; @@ -2264,6 +2271,7 @@ sub populate { ## do the belongs_to relationships foreach my $index (0..$#$data) { + next if (ref $data->[$index] eq 'CODE'); # delegate to list context populate()/create() for any dataset without # primary keys with specified relationships @@ -2313,6 +2321,7 @@ sub populate { ## do the has_many relationships foreach my $item (@$data) { + next if (ref $item eq 'CODE'); my $main_row;