fix double encoding on JSON UTF-8 custom fields

This commit is contained in:
Oliver Gorwits
2023-07-25 12:42:20 +01:00
parent 0b82499c77
commit e2ce601782
2 changed files with 14 additions and 5 deletions

View File

@@ -8,6 +8,7 @@ use App::Netdisco::Util::Device
use App::Netdisco::Backend::Job;
use Module::Load ();
use JSON::PP ();
use Try::Tiny;
use base 'Exporter';
@@ -356,8 +357,9 @@ sub jq_insert {
die 'failed to find row for custom field update' unless $row;
my $coder = JSON::PP->new->utf8(0)->allow_nonref(1)->allow_unknown(1);
$spec->{subaction} = $coder->encode( $spec->{extra} || $spec->{subaction} );
$spec->{action} =~ s/^cf_//;
$spec->{subaction} = to_json( $spec->{extra} || $spec->{subaction} );
$row->make_column_dirty('custom_fields');
$row->update({
custom_fields => \['jsonb_set(custom_fields, ?, ?)'