]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/DB/Result/Bug.pm
srcpackage insertion was inverted; fix
[debbugs.git] / Debbugs / DB / Result / Bug.pm
index 6da2a22db0333c206e4d4275ffdea3684c155cb0..6e559d41b9485f95e90b4eb79ba056b9402eebe9 100644 (file)
@@ -173,6 +173,14 @@ Individual who submitted this bug; empty if there is no submitter
 
 Package name if the package is not known
 
+=head2 unknown_affects
+
+  data_type: 'text'
+  default_value: (empty string)
+  is_nullable: 0
+
+Package name if the affected package is not known
+
 =cut
 
 __PACKAGE__->add_columns(
@@ -227,6 +235,8 @@ __PACKAGE__->add_columns(
   { data_type => "text", default_value => "", is_nullable => 0 },
   "unknown_packages",
   { data_type => "text", default_value => "", is_nullable => 0 },
+  "unknown_affects",
+  { data_type => "text", default_value => "", is_nullable => 0 },
 );
 
 =head1 PRIMARY KEY
@@ -514,11 +524,11 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07045 @ 2016-09-24 14:51:07
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:iaipVETTaokcFNrICfIEAw
+# Created by DBIx::Class::Schema::Loader v0.07048 @ 2018-04-11 13:06:55
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qxkLXbv8JGoV9reebbOUEw
 
 use Carp;
-use List::Util qw(uniq);
+use List::AllUtils qw(uniq);
 
 __PACKAGE__->many_to_many(tags => 'bug_tags','tag');
 __PACKAGE__->many_to_many(user_tags => 'bug_user_tags','user_tag');
@@ -546,21 +556,47 @@ sub sqlt_deploy_hook {
     }
 }
 
+=head1 Utility Functions
+
+=cut
+
+=head2 set_related_packages
+
+ $b->set_related_packages($relationship,
+                         \@packages,
+                         $package_cache ,
+                        );
+
+Set bug-related packages.
+
+=cut
+
 sub set_related_packages {
     my ($self,$relationship,$pkgs,$pkg_cache) = @_;
 
+    my @unset_packages;
     my @pkg_ids;
     if ($relationship =~ /binpackages/) {
         for my $pkg (@{$pkgs}) {
-            push @pkg_ids,
+           my $pkg_id =
               $self->result_source->schema->resultset('BinPkg')->
               get_bin_pkg_id($pkg);
+           if (not defined $pkg_id) {
+               push @unset_packages,$pkg;
+           } else {
+              push @pkg_ids, $pkg_id;
+           }
         }
     } elsif ($relationship =~ /srcpackages/) {
         for my $pkg (@{$pkgs}) {
-            push @pkg_ids,
+           my $pkg_id =
               $self->result_source->schema->resultset('SrcPkg')->
               get_src_pkg_id($pkg);
+           if (not defined $pkg_id) {
+               push @unset_packages,$pkg;
+           } else {
+               push @pkg_ids,$pkg_id;
+           }
         }
     } else {
         croak "Unsupported relationship $relationship";
@@ -577,6 +613,7 @@ sub set_related_packages {
     } else {
         croak "Unsupported relationship $relationship";
     }
+    return @unset_packages
 }
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
 1;