On 11/27/06 5:34 PM, Jud wrote:
> I'd like to do something like:
> 
> my $project = Project->new( id => 1)->load;
> for my $contact ( $project->users( with_map_records => 1 ) ) {
> print $contact->map_record->role, ":" , $contact->name, "\n";
> }

I considered adding this feature when I addressed your earlier post, but the
problem is that the user() method (i.e., the objects_by_map get_set_on_save
method) accepts arguments in the following forms:

    * A single undef arg
    * A list containing any combination of the following:
        - An object of the appropriate class
        - A reference to a hash containing method name/value pairs
        - A scalar primary key value

It's that last one that causes problem.  The arguments you suggested look
like two scalar primary key values, "with_map_records" and "1".

So, asking that map records be included on a per-method-call basis is
probably out.  But if you *always* want map records with your m-to-m
objects, just add to the relationship's manager_args:

    relationships =>
    [
      users =>
      {
        type         => 'many to many',
        map_class    => 'ProjectUserMap ',
        manager_args => { with_map_records => 1 },
      },
      ...
    ]

Even if you only want the map records sometimes, asking for them always
shouldn't add much overhead.  Map records tend to be small.

-John



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to