Skip Menu |

This queue is for tickets about the DBIx-Class-ResultSet-RecursiveUpdate CPAN distribution.

Report information
The Basics
Id: 77265
Status: resolved
Priority: 0/
Queue: DBIx-Class-ResultSet-RecursiveUpdate

People
Owner: Nobody in particular
Requestors: LUKAST [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.25
Fixed in: (no value)



Subject: recursive update dies when updating has_many relations with complex "where" conditions
Recursive update dies with "ambiguous column name" when has_many relations with complex where-conditions are updated. The problem can easily be solved by adding "me" to the column names in _update_relations. See the attached tests and patch. Since the schema where the problem originated is HUGE, I have created a simple example schema to illustrate the issue. See "true_relateditems" in t/lib/AnotherTestDB/OnePK/Schema/Result/Item.pm for the conditional has_many relationship.
Subject: conditional_hasmany_test.tar.bz2

Message body not shown because it is not plain text.

Subject: conditional_hasmany.patch
--- /home/lukast/perl5/perlbrew/perls/perl-5.14.2_threads/lib/site_perl/5.14.2/DBIx/Class/ResultSet/RecursiveUpdate.pm 2012-04-13 04:18:54.000000000 +0200 +++ lib/DBIx/Class/ResultSet/RecursiveUpdate.pm 2012-05-17 21:41:14.000000000 +0200 @@ -368,12 +368,13 @@ my @related_pks = $related_resultset->result_source->primary_columns; + my $rs_rel_delist = $object->$name; # foreign table has a single pk column if ( scalar @related_pks == 1 ) { $rs_rel_delist = $rs_rel_delist->search_rs( - { $related_pks[0] => + { 'me.'. $related_pks[0] => { -not_in => [ map ( $_->id, @updated_objs ) ] } } ); @@ -385,7 +386,7 @@ for my $obj (@updated_objs) { my %cond_for_obj; for my $col (@related_pks) { - $cond_for_obj{$col} = $obj->get_column($col); + $cond_for_obj{"me.$col"} = $obj->get_column($col); } push @cond, \%cond_for_obj; }
Thanks, Lukas.