Subject: | Implementation of add_to_foo method for many-to-many relationships is dangerous |
The implementation¹ of the add_to_foo method for many-to-many relationships is dangerous, as it performs a find_or_create when given a hashref instead of just a create like the add_to_foo methods of other relationships.
The documentation² indicates that it should be just a create. Even if this is the desired behaviour and the documentation needs updating, that find_or_create is located in a place where it's impossible to pass in a second argument to specify a unique constraint to use for find.
¹ https://github.com/Perl5/DBIx-Class/blob/maint/0.0828xx/lib/DBIx/Class/Relationship/ManyToMany.pm#L94-L102
² https://metacpan.org/pod/DBIx::Class::Relationship::Base#add_to_$rel