Skip to content

Commit

Permalink
Fix use of merge() to work with newer Hash::Merge
Browse files Browse the repository at this point in the history
Fix provided by @ribasushi -- recent versions of Hash::Merge involved
breaking changes due to different default clone behavior. Update call to
merge() to set explicit options to get back to the original behavior
(and still work with older versions of Hash::Merge)
  • Loading branch information
vanstyn committed Jan 16, 2018
1 parent 508c237 commit 7ba9582
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions lib/DBIx/Class/Schema/Loader.pm
Expand Up @@ -8,9 +8,8 @@ use mro 'c3';
use Carp::Clan qw/^DBIx::Class/;
use Scalar::Util 'weaken';
use Sub::Util 'set_subname';
use DBIx::Class::Schema::Loader::Utils 'array_eq';
use DBIx::Class::Schema::Loader::Utils qw/array_eq sigwarn_silencer/;
use Try::Tiny;
use Hash::Merge 'merge';
use curry;
use namespace::clean;

Expand Down Expand Up @@ -233,13 +232,28 @@ sub _merge_state_from {

$self->_copy_state_from($from);

$self->class_mappings(merge($orig_class_mappings, $self->class_mappings))
$self->class_mappings(__merge($orig_class_mappings, $self->class_mappings))
if $orig_class_mappings;

$self->source_registrations(merge($orig_source_registrations, $self->source_registrations))
$self->source_registrations(__merge($orig_source_registrations, $self->source_registrations))
if $orig_source_registrations;
}

my $merger;
sub __merge {

local $SIG{__WARN__} = sigwarn_silencer(qr/Arguments for _merge_hashes must be hash references/);

( $merger ||= do {
require Hash::Merge;
my $m = Hash::Merge->new('LEFT_PRECEDENT');
$m->set_clone_behavior(0);
$m;
} )->merge(
$_[0], $_[1]
);
}

sub _copy_state_from {
my $self = shift;
my ($from) = @_;
Expand Down

0 comments on commit 7ba9582

Please sign in to comment.