[Bast-commits] r6469 - in DBIx-Class/0.08/trunk: . lib/DBIx/Class t
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Sat May 30 17:46:09 GMT 2009
Author: ribasushi
Date: 2009-05-30 17:46:09 +0000 (Sat, 30 May 2009)
New Revision: 6469
Modified:
DBIx-Class/0.08/trunk/Changes
DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
DBIx-Class/0.08/trunk/t/100populate.t
Log:
populate() fix and Changes
Modified: DBIx-Class/0.08/trunk/Changes
===================================================================
--- DBIx-Class/0.08/trunk/Changes 2009-05-30 17:37:00 UTC (rev 6468)
+++ DBIx-Class/0.08/trunk/Changes 2009-05-30 17:46:09 UTC (rev 6469)
@@ -1,5 +1,10 @@
Revision history for DBIx::Class
+ - populate() now properly reports the dataset slice in case of
+ an exception
+ - fixed corner case when populate() erroneously falls back to
+ create()
+
0.08103 2009-05-26 19:50:00 (UTC)
- Multiple $resultset -> count/update/delete fixes. Now any
of these operations will succeed, regardless of the complexity
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm 2009-05-30 17:37:00 UTC (rev 6468)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm 2009-05-30 17:46:09 UTC (rev 6469)
@@ -1665,13 +1665,19 @@
## do the belongs_to relationships
foreach my $index (0..$#$data) {
- if( grep { !defined $data->[$index]->{$_} } @pks ) {
- my @ret = $self->populate($data);
- return;
+
+ # delegate to create() for any dataset without primary keys with specified relationships
+ if (grep { !defined $data->[$index]->{$_} } @pks ) {
+ for my $r (@rels) {
+ if (grep { ref $data->[$index]{$r} eq $_ } qw/HASH ARRAY/) { # a related set must be a HASH or AoH
+ my @ret = $self->populate($data);
+ return;
+ }
+ }
}
foreach my $rel (@rels) {
- next unless $data->[$index]->{$rel} && ref $data->[$index]->{$rel} eq "HASH";
+ next unless ref $data->[$index]->{$rel} eq "HASH";
my $result = $self->related_resultset($rel)->create($data->[$index]->{$rel});
my ($reverse) = keys %{$self->result_source->reverse_relationship_info($rel)};
my $related = $result->result_source->_resolve_condition(
Modified: DBIx-Class/0.08/trunk/t/100populate.t
===================================================================
--- DBIx-Class/0.08/trunk/t/100populate.t 2009-05-30 17:37:00 UTC (rev 6468)
+++ DBIx-Class/0.08/trunk/t/100populate.t 2009-05-30 17:46:09 UTC (rev 6469)
@@ -39,7 +39,6 @@
$schema->populate('CD', [
map {
{
- cdid => $i++, # without a PK the bulk insert does not engage - how come?
artist => $artist->id,
title => $_,
year => 2009,
More information about the Bast-commits
mailing list