Title: [opsview] [9596] Don't delete from and select from the same table at the same time.
Revision
9596
Author
pknight
Date
2012-07-20 16:24:28 +0100 (Fri, 20 Jul 2012)

Log Message

Don't delete from and select from the same table at the same time.

Modified Paths


Modified: trunk/opsview-core/lib/Opsview/Schema/Roles.pm
===================================================================
--- trunk/opsview-core/lib/Opsview/Schema/Roles.pm	2012-07-20 15:24:01 UTC (rev 9595)
+++ trunk/opsview-core/lib/Opsview/Schema/Roles.pm	2012-07-20 15:24:28 UTC (rev 9596)
@@ -202,8 +202,8 @@
             class => "Opsview::Schema::Keywords",
         },
 
-        # Even though contacts is a has_many relationship, we make this into a multi to find suitable
-        # contacts when editing
+        # Even though contacts is a has_many relationship, we make this into a
+        # multi to find suitable contacts when editing.
         # I'm sure something is not right here
         "contacts" => {
             type  => "multi",
@@ -264,7 +264,9 @@
       );
     $rs = $rs->search( { "contact.id" => $contact_id } ) if $contact_id;
     @valid = map { $_->id } ( $self->valid_hostgroups->all );
-    $rs->search( { "hostgroupid" => { -not_in => \@valid } } )->delete;
+    my @invalid_hostgroups =
+      $rs->search( { "hostgroupid" => { -not_in => \@valid } } )->all;
+    $_->delete for @invalid_hostgroups;
 
     $rs = $self->result_source->schema->resultset(
         "NotificationprofileServicegroups")->search(
@@ -273,7 +275,9 @@
         );
     $rs = $rs->search( { "contact.id" => $contact_id } ) if $contact_id;
     @valid = map { $_->id } ( $self->valid_servicegroups->all );
-    $rs->search( { "servicegroupid" => { -not_in => \@valid } } )->delete;
+    @invalid_hostgroups =
+      $rs->search( { "servicegroupid" => { -not_in => \@valid } } )->all;
+    $_->delete for @invalid_hostgroups;
 
     $rs =
       $self->result_source->schema->resultset("NotificationprofileKeywords")
@@ -283,7 +287,9 @@
       );
     $rs = $rs->search( { "contact.id" => $contact_id } ) if $contact_id;
     @valid = map { $_->id } ( $self->valid_keywords->all );
-    $rs->search( { "keywordid" => { -not_in => \@valid } } )->delete;
+    @invalid_hostgroups =
+      $rs->search( { "keywordid" => { -not_in => \@valid } } )->all;
+    $_->delete for @invalid_hostgroups;
 
 }
 

_______________________________________________
Opsview-checkins mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to