[Bast-commits] r7303 - in DBIx-Class/0.08/trunk: lib/DBIx/Class
t/inflate t/lib/DBICTest/Schema
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Tue Aug 11 18:00:13 GMT 2009
Author: ribasushi
Date: 2009-08-11 18:00:11 +0000 (Tue, 11 Aug 2009)
New Revision: 7303
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm
DBIx-Class/0.08/trunk/t/inflate/serialize.t
DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/Serialized.pm
Log:
Fix an obscure regression when inserting an object with a serialize-deflating column set
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm 2009-08-11 17:40:59 UTC (rev 7302)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Row.pm 2009-08-11 18:00:11 UTC (rev 7303)
@@ -354,18 +354,17 @@
$self->{related_resultsets} = {};
foreach my $relname (keys %related_stuff) {
- my $rel_obj = $related_stuff{$relname};
- my @cands;
- if (Scalar::Util::blessed($rel_obj)
- && $rel_obj->isa('DBIx::Class::Row'))
- {
- @cands = ($rel_obj);
- }
- elsif (ref $rel_obj eq 'ARRAY') {
- @cands = @$rel_obj;
- }
+ next unless $source->has_relationship ($relname);
- if (@cands) {
+ my @cands = ref $related_stuff{$relname} eq 'ARRAY'
+ ? @{$related_stuff{$relname}}
+ : $related_stuff{$relname}
+ ;
+
+ if (@cands
+ && Scalar::Util::blessed($cands[0])
+ && $cands[0]->isa('DBIx::Class::Row')
+ ) {
my $reverse = $source->reverse_relationship_info($relname);
foreach my $obj (@cands) {
$obj->set_from_related($_, $self) for keys %$reverse;
Modified: DBIx-Class/0.08/trunk/t/inflate/serialize.t
===================================================================
--- DBIx-Class/0.08/trunk/t/inflate/serialize.t 2009-08-11 17:40:59 UTC (rev 7302)
+++ DBIx-Class/0.08/trunk/t/inflate/serialize.t 2009-08-11 18:00:11 UTC (rev 7303)
@@ -71,10 +71,17 @@
$object = $rs->create( {
serialized => '',
} );
-eval { $object->set_inflated_column('serialized', $struct_hash) };
-ok(!$@, 'set_inflated_column to a hashref');
+$object->set_inflated_column('serialized', $struct_hash);
is_deeply($object->serialized, $struct_hash, 'inflated hash matches original');
+$object = $rs->new({});
+$object->serialized ($struct_hash);
+$object->insert;
+is_deeply (
+ $rs->find ({id => $object->id})->serialized,
+ $struct_hash,
+ 'new/insert works',
+);
#====== testing arrayref serialization
@@ -82,8 +89,16 @@
ok($inflated = $object->serialized, 'arrayref inflation');
is_deeply($inflated, $struct_array, 'inflated array matches original');
+$object = $rs->new({});
+$object->serialized ($struct_array);
+$object->insert;
+is_deeply (
+ $rs->find ({id => $object->id})->serialized,
+ $struct_array,
+ 'new/insert works',
+);
-#===== make sure make_column_dirty ineracts reasonably with inflation
+#===== make sure make_column_dirty interacts reasonably with inflation
$object = $rs->first;
$object->update ({serialized => { x => 'y'}});
Modified: DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/Serialized.pm
===================================================================
--- DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/Serialized.pm 2009-08-11 17:40:59 UTC (rev 7302)
+++ DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/Serialized.pm 2009-08-11 18:00:11 UTC (rev 7303)
@@ -5,7 +5,7 @@
__PACKAGE__->table('serialized');
__PACKAGE__->add_columns(
- 'id' => { data_type => 'integer' },
+ 'id' => { data_type => 'integer', is_auto_increment => 1 },
'serialized' => { data_type => 'text' },
);
__PACKAGE__->set_primary_key('id');
More information about the Bast-commits
mailing list