0

I have the following relationship on my Entry result class:

package Schema::Result::Entry;
__PACKAGE__->has_many(
  "entry_i18ns",
  "Schema::Result::EntryI18n",
  { "foreign.entry_id" => "self.id" },
  { cascade_copy => 0, cascade_delete => 0 },
);

So i want to retrieve related data from a newly created Schema::Result::Entry object:

$result = $schema->resultset('Result')->create({ entry_i18ns => { title => 'foo', language_code => 'en' } });

The problem is that entry_i18ns accessor executes extra SELECT and returns all the related EntryI18n objects, not the specific one which was created with create() call.

As far as i can see, data i need is stored with $result->{_relationship_data}{entry_i18ns} array ref so i can access it whith something like

my $related_data = $result->{_relationship_data}{entry_i18ns}[0]{_column_data};

But how can i do it without messing up with internal DBIC private storage?

romel
  • 97
  • 5

1 Answers1

1

No accessor for this in DBIC. An accessors for a “multi” relationship always do new select. But you can create own component which adds that accessor. Or just add method to the result class.

Denis Ibaev
  • 2,470
  • 23
  • 29