my @cond;
my @related_pks = $related_resultset->result_source->primary_columns;
- for my $obj (@updated_objs) {
- my %cond_for_obj;
- for my $col (@related_pks) {
- $cond_for_obj{$col} = $obj->get_column($col);
+
+ 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] =>
+ { -not_in => [ map ( $_->id, @updated_objs ) ] }
+ }
+ );
+ }
+ # foreign table has multiple pk columns
+ else {
+ for my $obj (@updated_objs) {
+ my %cond_for_obj;
+ for my $col (@related_pks) {
+ $cond_for_obj{$col} = $obj->get_column($col);
+ }
+ push @cond, \%cond_for_obj;
}
- push @cond, \%cond_for_obj;
+ $rs_rel_delist = $rs_rel_delist->search_rs({ -not => [@cond] });
}
- my %cond = ( -not => [@cond] );
#warn "\tCOND: " . Dumper(\%cond);
- my $rs_rel_delist = $object->$name->search_rs( \%cond );
-
#my $rel_delist_cnt = $rs_rel_delist->count;
- my @foo = $rs_rel_delist->all;
if ( $if_not_submitted eq 'delete' ) {
#warn "\tdeleting related rows: $rel_delist_cnt\n";