From: Henry Van Styn Date: Wed, 29 Oct 2014 13:25:33 +0000 (-0400) Subject: Fix uninitialized warnings on empty hashes passed to join/prefetch X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ca30d840cc713dd8ee5cde0925a8b84b9b85f4c5;p=dbsrgits%2FDBIx-Class-Historic.git Fix uninitialized warnings on empty hashes passed to join/prefetch --- diff --git a/.mailmap b/.mailmap index 22615b3..ee01f0a 100644 --- a/.mailmap +++ b/.mailmap @@ -29,6 +29,7 @@ Gerda Shank Gianni Ceccarelli Gordon Irving Hakim Cassimally +Henry Van Styn Jason M. Mills Jonathan Chu Jose Luis Martinez diff --git a/AUTHORS b/AUTHORS index 6a9f6ef..4a56099 100644 --- a/AUTHORS +++ b/AUTHORS @@ -200,6 +200,7 @@ triode: Pete Gamache typester: Daisuke Murase uree: Oriol Soriano uwe: Uwe Voelker +vanstyn: Henry Van Styn victori: Victor Igumnov wdh: Will Hawes wesm: Wes Malone diff --git a/Changes b/Changes index e64e82e..e617f91 100644 --- a/Changes +++ b/Changes @@ -16,6 +16,9 @@ Revision history for DBIx::Class http://lists.scsys.co.uk/pipermail/dbix-class/2015-January/011903.html - Fix incorrect collapsing-parser source being generated in the presence of unicode data among the collapse-points + - Fix uninitialized warnings on empty hashes passed to join/prefetch + https://github.com/vanstyn/RapidApp/commit/6f41f6e48 and + http://lists.scsys.co.uk/pipermail/dbix-class/2015-February/011921.html - Fix endless loop on BareSourcelessResultClass->throw_exception(...) - Fix hang in t/72pg.t when run against DBD::Pg 3.5.0. The ping() implementation changes due to RT#100648 made an alarm() based diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index cf1298e..7e4cb4d 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -3813,8 +3813,10 @@ sub _calculate_score { if (ref $b eq 'HASH') { my ($b_key) = keys %{$b}; + $b_key = '' if ! defined $b_key; if (ref $a eq 'HASH') { my ($a_key) = keys %{$a}; + $a_key = '' if ! defined $a_key; if ($a_key eq $b_key) { return (1 + $self->_calculate_score( $a->{$a_key}, $b->{$b_key} )); } else { diff --git a/xt/extra/internals/merge_joinpref_attr.t b/xt/extra/internals/merge_joinpref_attr.t index 0e9f601..bb77358 100644 --- a/xt/extra/internals/merge_joinpref_attr.t +++ b/xt/extra/internals/merge_joinpref_attr.t @@ -6,8 +6,6 @@ use lib qw(t/lib); use DBICTest; use Test::More; -plan tests => 15; - my $schema = DBICTest->init_schema(); my $rs = $schema->resultset( 'CD' ); @@ -131,5 +129,20 @@ my $rs = $schema->resultset( 'CD' ); is_deeply( $result, $expected ); } +{ + my $a = [ { 'artist' => { 'manager' => {} } }, 'cd' ]; + my $b = [ 'artist', { 'artist' => { 'manager' => {} } } ]; + my $expected = [ { 'artist' => { 'manager' => {} } }, 'cd', { 'artist' => { 'manager' => {} } } ]; + my $result = $rs->_merge_joinpref_attr($a, $b); + is_deeply( $result, $expected ); +} + +{ + my $a = [ { 'artist' => { 'manager' => undef } }, 'cd' ]; + my $b = [ 'artist', { 'artist' => { 'manager' => undef } } ]; + my $expected = [ { 'artist' => { 'manager' => undef } }, 'cd', { 'artist' => { 'manager' => undef } } ]; + my $result = $rs->_merge_joinpref_attr($a, $b); + is_deeply( $result, $expected ); +} -1; +done_testing;