From 8b6b969b97f5c52d39a04ff154f02f8f589e2040 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Tue, 28 Apr 2020 16:59:58 -0700 Subject: [PATCH] DualIndexHashObject: do not overwrite existing data when adding --- PBot/DualIndexHashObject.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/PBot/DualIndexHashObject.pm b/PBot/DualIndexHashObject.pm index cd65907f..81873503 100644 --- a/PBot/DualIndexHashObject.pm +++ b/PBot/DualIndexHashObject.pm @@ -348,7 +348,16 @@ sub add { $data->{_name} = $secondary_index; } - $self->{hash}->{$lc_primary_index}->{$lc_secondary_index} = $data; + if (exists $self->{hash}->{$lc_primary_index}->{$lc_secondary_index}) { + foreach my $key (keys %{$data}) { + if (not exists $self->{hash}->{$lc_primary_index}->{$lc_secondary_index}->{$key}) { + $self->{hash}->{$lc_primary_index}->{$lc_secondary_index}->{$key} = $data->{$key}; + } + } + } else { + $self->{hash}->{$lc_primary_index}->{$lc_secondary_index} = $data; + } + $self->save() unless $dont_save; my $name1 = $self->get_key_name($lc_primary_index);