Skip Menu |

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 58551
Status: new
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: EWILHELM [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.08123
Fixed in: (no value)



Subject: relations in non-inserted objects not accessible
An object created via $rs->new({..., cds => [ {...} ] }) should be fully operational without any parts of it having been sent to the database. However, calling $object->cds on such an object results in a trip to storage and returns a null list for the relation. The attached patch demonstrates this with a failing test. irc transcript: <ewilhelm> are relation accessors supposed to be available without making a trip to storage? <ribasushi> ewilhelm: should be yes
Subject: in_memory.t.patch
diff --git a/t/multi_create/in_memory.t b/t/multi_create/in_memory.t index cbd5309..73563eb 100644 --- a/t/multi_create/in_memory.t +++ b/t/multi_create/in_memory.t @@ -19,6 +19,19 @@ my $schema = DBICTest->init_schema(); # relations whose PK's are necessary to complete the objects supplied # to new(). All other objects should be insert()able afterwards too. +{ + my $queries = 0; + $schema->storage->debugcb(sub { $queries++; }); + $schema->storage->debug(1); + my $new_artist = $schema->resultset("Artist")->new_result({ + 'name' => 'Depeche Mode', + cds => [{ 'title' => 'Leave in Silence', 'year' => 1982 }] + }); + is($new_artist->name, 'Depeche Mode', 'scalar accessor works'); + is($queries, 0, 'no queries run'); + is(scalar($new_artist->cds), 1, 'relation via in-memory object'); + is($queries, 0, 'no queries run'); +} { my $new_artist = $schema->resultset("Artist")->new_result({ 'name' => 'Depeche Mode' });