I have gone down a similar path before,

http://www.mail-archive.com/rose-db-object@lists.sourceforge.net/msg01792.html

The short story is that a map_record is not designed to be
manipulated, it's only there for convenience when fetching related
objects from a many-to-many relationship call, such as

foreach my $user ($company->users) { # map record makes sense here

and because of it's simple design, should not be used for manipulating
the map record.

When you need to manipulate the map records themselves, setup an
additional one-to-many relationship in My::Company called "user_maps"
(or whatever you like) that relates to My::CompanyUser (which is the
class that does your many-to-many) so that you can easily say

$company->add_user_maps(
  {
    restricted => 'true',
    user => My::User->new(username => 'bob')
  }
);

and all is peachy.

On 5/17/07, Wiggins d'Anconia <[EMAIL PROTECTED]> wrote:
> I'm fairly new to the "with_map_records" manager arg, and possibly this
> is already available but I couldn't find documentation or an easy way to
> achieve it. Is it possible to set fields of the mapping table during an
> "add" operation. For example:
>
> $company->add_users(
>    {
>      username => 'bob',
>      map_records => {
>        restricted => 'true',
>      },
>    },
> );
>
> So I am adding a user to a relationship in the company class that has
> with_manager_args => 1, but want the mapping table to get the value of
> 'restricted'?
>
> The best I have come up with is to add the user, then get a list of all
> users with map records, loop through that list finding my user, and grab
> the map_record and set the fields on it directly (or get the list of the
> single user directly from the manager class, or get the map record
> directly from the manager of the map class).
>
> Thanks for any assistance, obviously I think a shortcut of this nature
> would be pretty handy, unfortunately I don't (yet) know enough of the
> internals to know where to begin a patch.
>
> http://danconia.org
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Rose-db-object mailing list
> Rose-db-object@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rose-db-object
>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to