Sometimes I think i'm missing something obvious.
In my application, for instance, a holiday can be assigned to a group.
A group has many donors
A donor might have many scheduled days
A scheduled day is associated with a particular schedule
In this spot in my application, the operation is "update group schedule" .
I need to say "refresh all of the randomized scheduling for all of the
schedules related to all of the donors in the group this schedule is
on." To do that I need a list of those schedules.
I first wrote that, for an update overload in my holiday class, like
this. ($old is a hash ref to a copy of the get_columns from before the
update took place)
$self->groups->donors->schedule->ivr_schedule->search(
{ 'date_start' => { '<=' => $old->{holiday} }
, -or =>
[ 'date_end' => { '>=' => $old->{holiday} }
, 'date_end' => undef
]
} );
But I got an error, something like "No such method 'donors' on class
DBIx::Class::ResultSet"
So I rewrote it...
$self->groups->search_related('donors')->search_related('schedule')->search_related('ivr_schedule'
, ...yaddayadda...
and that worked.
So it leaves me wondering if I missed something fundamental here. I
have an object which is a result set of a particular record type. If I
want the records that are related to that result set - why would I have
to call 'related_resultset' - isn't "give me the related resulset" the
only thing I could mean when I call ->relationship on a result set? If
that is so, why aren't there accessors created on the resultset for the
valid relations, to cut down on excessive verbosity that doesn't clarify?
Curious,
David
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]