#1072 clean custom_fields keys on rediscover

This commit is contained in:
Oliver Gorwits
2023-07-19 22:18:00 +01:00
parent 1067b82dc6
commit f8222e7890
3 changed files with 44 additions and 5 deletions

View File

@@ -338,12 +338,18 @@ sub jq_insert {
if ($spec->{port}) {
$row = schema(vars->{'tenant'})->resultset('DevicePort')
->find($spec->{port}, $spec->{device});
undef $row unless
scalar grep {('cf_'. $_) eq $spec->{action}}
@{ setting('_device_port_custom_fields') || [] };
}
else {
$row = schema(vars->{'tenant'})->resultset('Device')
->find($spec->{device});
undef $row unless
scalar grep {('cf_'. $_) eq $spec->{action}}
@{ setting('_device_custom_fields') || [] };
}
undef $row unless $row->can($spec->{action});
die 'failed to find row for custom field update' unless $row;
$spec->{action} =~ s/^cf_//;