[Bast-commits] r3604 - in trunk/DBIx-Class: . lib/DBIx/Class t
captainL at dev.catalyst.perl.org
captainL at dev.catalyst.perl.org
Thu Jul 26 22:31:09 GMT 2007
Author: captainL
Date: 2007-07-26 22:31:08 +0100 (Thu, 26 Jul 2007)
New Revision: 3604
Modified:
trunk/DBIx-Class/Changes
trunk/DBIx-Class/lib/DBIx/Class/Row.pm
trunk/DBIx-Class/t/96multi_create.t
Log:
applied patch from davinch: fix bug with create_multi not inserting non-storage objects
Modified: trunk/DBIx-Class/Changes
===================================================================
--- trunk/DBIx-Class/Changes 2007-07-25 21:41:32 UTC (rev 3603)
+++ trunk/DBIx-Class/Changes 2007-07-26 21:31:08 UTC (rev 3604)
@@ -1,5 +1,6 @@
Revision history for DBIx::Class
-
+ - fix bug with create_multi not inserting non-storage objects
+ (test and fix from davinchi)
- DBIx::Class::AccessorGroup made empty subclass of
Class::Accessor::Grouped
- fixed an ugly bug regarding $dbh->{AutoCommit} and transactions
Modified: trunk/DBIx-Class/lib/DBIx/Class/Row.pm
===================================================================
--- trunk/DBIx-Class/lib/DBIx/Class/Row.pm 2007-07-25 21:41:32 UTC (rev 3603)
+++ trunk/DBIx-Class/lib/DBIx/Class/Row.pm 2007-07-26 21:31:08 UTC (rev 3604)
@@ -76,8 +76,10 @@
my $rel_obj = delete $attrs->{$key};
if(!Scalar::Util::blessed($rel_obj)) {
$rel_obj = $new->find_or_new_related($key, $rel_obj);
- $new->{_rel_in_storage} = 0 unless ($rel_obj->in_storage);
}
+
+ $new->{_rel_in_storage} = 0 unless ($rel_obj->in_storage);
+
$new->set_from_related($key, $rel_obj);
$related->{$key} = $rel_obj;
next;
@@ -90,6 +92,8 @@
$rel_obj = $new->new_related($key, $rel_obj);
$new->{_rel_in_storage} = 0;
}
+
+ $new->{_rel_in_storage} = 0 unless ($rel_obj->in_storage);
}
$related->{$key} = $others;
next;
Modified: trunk/DBIx-Class/t/96multi_create.t
===================================================================
--- trunk/DBIx-Class/t/96multi_create.t 2007-07-25 21:41:32 UTC (rev 3603)
+++ trunk/DBIx-Class/t/96multi_create.t 2007-07-26 21:31:08 UTC (rev 3604)
@@ -127,3 +127,37 @@
});
ok($cdp, 'join table record created ok');
+
+SPECIAL_CASE: {
+ my $kurt_cobain = { name => 'Kurt Cobain' };
+
+ my $in_utero = $schema->resultset('CD')->new({
+ title => 'In Utero',
+ year => 1993
+ });
+
+ $kurt_cobain->{cds} = [ $in_utero ];
+
+
+ $schema->resultset('Artist')->populate([ $kurt_cobain ]); # %)
+ $a = $schema->resultset('Artist')->find({name => 'Kurt Cobain'});
+
+ is($a->name, 'Kurt Cobain', 'Artist insertion ok');
+ is($a->cds && $a->cds->first && $a->cds->first->title,
+ 'In Utero', 'CD insertion ok');
+}
+
+SPECIAL_CASE2: {
+ my $pink_floyd = { name => 'Pink Floyd' };
+
+ my $the_wall = { title => 'The Wall', year => 1979 };
+
+ $pink_floyd->{cds} = [ $the_wall ];
+
+
+ $schema->resultset('Artist')->populate([ $pink_floyd ]); # %)
+ $a = $schema->resultset('Artist')->find({name => 'Pink Floyd'});
+
+ is($a->name, 'Pink Floyd', 'Artist insertion ok');
+ is($a->cds && $a->cds->first->title, 'The Wall', 'CD insertion ok');
+}
More information about the Bast-commits
mailing list