]> Dogcows Code - chaz/p5-DBIx-Class-ResultSet-RecursiveUpdate/blobdiff - lib/DBIx/Class/ResultSet/RecursiveUpdate.pm
Workaround not needed any more
[chaz/p5-DBIx-Class-ResultSet-RecursiveUpdate] / lib / DBIx / Class / ResultSet / RecursiveUpdate.pm
index 5934bc4936957a5c2e85fb6514cc3583271cf74d..de9ee41ab3b0cee487032b3f2c4bf4ada6010360 100644 (file)
@@ -11,17 +11,12 @@ use base qw(DBIx::Class::ResultSet);
 sub recursive_update { 
     my( $self, $updates ) = @_;
     my $object;
 sub recursive_update { 
     my( $self, $updates ) = @_;
     my $object;
-    # this is a workaround for a bug in the svn version 4794 
-    if ( ref $self->{cond} eq 'ARRAY' and ref $self->{cond}[0] eq 'SCALAR' ){
-        $self->{cond} = {};
-        $object = $self->new( {} );
-    }
-    else {
-        $object = $self->find( $updates, { key => 'primary' } ) || $self->new( {} );
-    }
+    $object = $self->find( $updates, { key => 'primary' } ) || $self->new( {} );
 
 
-    for my $name ( keys %$updates ){ if($object->can($name)){
+    for my $name ( keys %$updates ){ 
+        if($object->can($name)){
             my $value = $updates->{$name};
             my $value = $updates->{$name};
+
             # updating relations that that should be done before the row is inserted into the database
             # like belongs_to
             if( $object->result_source->has_relationship($name) 
             # updating relations that that should be done before the row is inserted into the database
             # like belongs_to
             if( $object->result_source->has_relationship($name) 
@@ -34,7 +29,6 @@ sub recursive_update {
                     _master_relation_cond( $object, $info->{cond}, _get_pk_for_related( $object, $name ) )
                 ){
                     my $related_result = $object->related_resultset( $name );
                     _master_relation_cond( $object, $info->{cond}, _get_pk_for_related( $object, $name ) )
                 ){
                     my $related_result = $object->related_resultset( $name );
-                    $DB::single = 1;
                     my $sub_object = $related_result->recursive_update( $value );
                     $object->set_from_related( $name, $sub_object );
                 }
                     my $sub_object = $related_result->recursive_update( $value );
                     $object->set_from_related( $name, $sub_object );
                 }
@@ -197,12 +191,22 @@ Then:
     put 'undef' for the key value - this is then removed
     and a correct INSERT statement is generated.  
 
     put 'undef' for the key value - this is then removed
     and a correct INSERT statement is generated.  
 
+    For a many_to_many (pseudo) relation you can supply a list of primary keys
+    from the other table - and it will link the record at hand to those and
+    only those records identified by them.  This is convenient for handling web
+    forms with check boxes (or a SELECT box with multiple choice) that let you
+    update such (pseudo) relations.
+
     For a description how to set up base classes for ResultSets see load_namespaces
     in DBIx::Class::Schema.
 
     For a description how to set up base classes for ResultSets see load_namespaces
     in DBIx::Class::Schema.
 
+    The support for many to many pseudo relationships should be treated as prototype -
+    the DBIC author disagrees with the way I did it.
+
+
 =head1 INTERFACE 
 
 =head1 INTERFACE 
 
-=for author to fill in:
+=for uthor to fill in:
 
 =head1 METHODS
 
 
 =head1 METHODS
 
This page took 0.02241 seconds and 4 git commands to generate.