fix error when using API /api/v1/object/device/ip/port_vlans
This commit is contained in:
1
Changes
1
Changes
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user