set_$helper_name replaces all rows in the link table, add_to_$helper_name adds
a row to the link table.
If you look at the code in DBIx::Class::Relationship::ManyToMany you see that
set_ deletes all rows and then calls the add_to_ method for every array
element, so the syntax is the same.
The pod contains an example for its usage:
$actor->add_to_roles($role, { year => 1995 });
The first argument is a role object, the optional second parameter a hashref
containing additional column data for the link table.
Am 2012-02-21 19:23, schrieb David Cantrell:
On Tue, Feb 21, 2012 at 06:24:03PM +0100, Alexander Hartmaier wrote:
You can find an example in the many_to_many relationship bridge docs:
https://metacpan.org/module/DBIx::Class::Relationship#many_to_many
Nothing helpful there I'm afraid, just an Exciting Bug (or maybe just a
not so exciting lack of documentation).
If I add this:
__PACKAGE__->many_to_many("user_roles_many_to_many" => 'user_roles', 'role');
Then if I have a user who already has role 'Philosophise' and do this:
...->set_user_roles_many_to_many(
[
{ role => { name => 'Philosophise' } }
]
);
Then it deletes all that user's records from the user_roles table (which
is, I presume, the correct behaviour before re-populating it), but then
generates this broken SQL:
SELECT role.id, role.name FROM role role WHERE ( role.role NAME 'Philosophise' )
Maybe I'm calling it wrong, but it's not at all obvious what I should be
doing as I can't see any documentation for the set_$method apart from
that it exists - I ASSumed that the data should look the same as when I'm
doing an INSERT!
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be
privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
_______________________________________________
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]