From: Matt S Trout Date: Sat, 26 Aug 2006 11:41:20 +0000 (+0000) Subject: Merge 'trunk' into 'DBIx-Class-current' X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bc577afb73970b01932a45d79590721e7b399846;hp=d5130dd2ecbb3a4d31393332f6b4e419f251f427;p=dbsrgits%2FDBIx-Class-Historic.git Merge 'trunk' into 'DBIx-Class-current' r26633@cain (orig r2733): jguenther | 2006-08-24 17:58:38 +0000 fixed set_$rel (from many_to_many) to accept a listref r26639@cain (orig r2739): jguenther | 2006-08-24 21:56:31 +0000 documented storage accessor in Schema r26640@cain (orig r2740): blblack | 2006-08-25 20:49:52 +0000 bump C3 reqs again r26641@cain (orig r2741): matthewt | 2006-08-25 21:49:09 +0000 fixes to many-many --- diff --git a/Build.PL b/Build.PL index cda0ada..2ba9d22 100644 --- a/Build.PL +++ b/Build.PL @@ -11,8 +11,7 @@ my %arguments = ( 'Scalar::Util' => 0, 'SQL::Abstract' => 1.20, 'SQL::Abstract::Limit' => 0.101, - 'Algorithm::C3' => 0.04, - 'Class::C3' => 0.11, + 'Class::C3' => 0.13, 'Storable' => 0, 'Class::Data::Accessor' => 0.01, 'Carp::Clan' => 0, diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index 9797b7c..8409165 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -410,7 +410,7 @@ B relationships.> =over 4 -=item Arguments: (@hashrefs | @objs) +=item Arguments: (\@hashrefs | \@objs) =back @@ -418,18 +418,22 @@ B relationships.> my @roles = $schema->resultset('Role')->search({ role => { '-in' -> ['Fred', 'Barney'] } } ); - $actor->set_roles(@roles); - # Replaces all of $actors previous roles with the two named + $actor->set_roles(\@roles); + # Replaces all of $actor's previous roles with the two named -Replace all the related objects with the given list of objects. This does a -C B to remove the association between the -current object and all related objects, then calls C repeatedly to -link all the new objects. +Replace all the related objects with the given reference to a list of +objects. This does a C B to remove the +association between the current object and all related objects, then calls +C repeatedly to link all the new objects. Note that this means that this method will B delete any objects in the table on the right side of the relation, merely that it will delete the link between them. +Due to a mistake in the original implementation of this method, it will also +accept a list of objects or hash references. This is B and will be +removed in a future version. + =head2 remove_from_$rel B relationships.> diff --git a/lib/DBIx/Class/Relationship/ManyToMany.pm b/lib/DBIx/Class/Relationship/ManyToMany.pm index 65eab45..e294a8c 100644 --- a/lib/DBIx/Class/Relationship/ManyToMany.pm +++ b/lib/DBIx/Class/Relationship/ManyToMany.pm @@ -60,8 +60,9 @@ sub many_to_many { @_ > 0 or $self->throw_exception( "{$set_meth} needs a list of objects or hashrefs" ); + my @to_set = (ref($_[0]) eq 'ARRAY' ? @{ $_[0] } : @_); $self->search_related($rel, {})->delete; - $self->$add_meth(shift) while (defined $_[0]); + $self->$add_meth($_) for (@to_set); }; *{"${class}::${remove_meth}"} = sub { diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index ee4b936..a2842be 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -171,6 +171,12 @@ For example: sub sources { return keys %{shift->source_registrations}; } +=head2 storage + + my $storage = $schema->storage; + +Returns the L object for this Schema. + =head2 resultset =over 4