fix error when using API /api/v1/object/device/ip/port_vlans

This commit is contained in:
Oliver Gorwits
2021-02-14 14:04:08 +00:00
parent 942e118e4d
commit 2e6bfa42b4
2 changed files with 16 additions and 1 deletions

View File

@@ -4,6 +4,7 @@
* #740 more robust log rotation
* #762 wide character error on deploy with local oui.txt
* error when using API /api/v1/object/device/ip/port_vlans
2.047002 - 2020-12-30

View File

@@ -5,7 +5,21 @@ use warnings;
use base 'DBIx::Class::Core';
__PACKAGE__->load_components(qw{Helper::Row::ToJSON});
BEGIN {
no warnings 'redefine';
__PACKAGE__->load_components(qw{Helper::Row::ToJSON});
# this replacement will avoid the issue of relation names which override
# field names, causing TO_JSON to return object instances, breaking to_json
*DBIx::Class::Helper::Row::ToJSON::TO_JSON = sub {
my $self = shift;
my $columns_info = $self->columns_info($self->serializable_columns);
my $columns_data = { $self->get_columns };
return {
map +($_ => $columns_data->{$_}), keys %$columns_info
};
};
}
# for DBIx::Class::Helper::Row::ToJSON
# to allow text columns to be included in results