From: Matt S Trout Date: Thu, 28 Dec 2006 19:24:41 +0000 (+0000) Subject: Merge 'source-handle' into 'DBIx-Class-current' X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f90375dd325063c09f0c07c80239d3b8e9f756f1;p=dbsrgits%2FDBIx-Class-Historic.git Merge 'source-handle' into 'DBIx-Class-current' --- f90375dd325063c09f0c07c80239d3b8e9f756f1 diff --cc lib/DBIx/Class/Row.pm index bd59293,0e77941..8360f37 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@@ -39,34 -41,12 +41,35 @@@ sub new if ($attrs) { $new->throw_exception("attrs must be a hashref") unless ref($attrs) eq 'HASH'; - if (my $source = delete $attrs->{-result_source}) { - $new->result_source($source); - } - - foreach my $k (keys %$attrs) { - $new->throw_exception("No such column $k on $class") - unless $class->has_column($k); - $new->store_column($k => $attrs->{$k}); + + my ($related,$inflated); + foreach my $key (keys %$attrs) { + if (ref $attrs->{$key}) { + my $info = $class->relationship_info($key); + if ($info && $info->{attrs}{accessor} + && $info->{attrs}{accessor} eq 'single') + { + $new->set_from_related($key, $attrs->{$key}); + $related->{$key} = $attrs->{$key}; + next; + } + elsif ($class->has_column($key) + && exists $class->column_info($key)->{_inflate_info}) + { + $inflated->{$key} = $attrs->{$key}; + next; + } + } + $new->throw_exception("No such column $key on $class") + unless $class->has_column($key); + $new->store_column($key => $attrs->{$key}); + } ++ if (my $source = delete $attrs->{-result_source}) { ++ $new->result_source($source); + } ++ + $new->{_relationship_data} = $related if $related; + $new->{_inflated_column} = $inflated if $inflated; } return $new;