Skip to content

Commit

Permalink
Fix uninitialized warnings on empty hashes passed to join/prefetch
Browse files Browse the repository at this point in the history
  • Loading branch information
vanstyn authored and ribasushi committed Mar 18, 2015
1 parent 16c65a3 commit ca30d84
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Gerda Shank <gshank@cpan.org> <gerda.shank@gmail.com>
Gianni Ceccarelli <dakkar@thenautilus.net> <gianni.ceccarelli@net-a-porter.com>
Gordon Irving <goraxe@cpan.org> <goraxe@goraxe.me.uk>
Hakim Cassimally <osfameron@cpan.org> <hakim@vm-participo.(none)>
Henry Van Styn <vanstyn@cpan.org> <vanstyn@intellitree.com>
Jason M. Mills <jmmills@cpan.org> <jmmills@cpan.org>
Jonathan Chu <milki@rescomp.berkeley.edu> <milki@rescomp.berkeley.edu>
Jose Luis Martinez <jlmartinez@capside.com> <jlmartinez@capside.com>
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ triode: Pete Gamache <gamache@cpan.org>
typester: Daisuke Murase <typester@cpan.org>
uree: Oriol Soriano <oriol.soriano@capside.com>
uwe: Uwe Voelker <uwe@uwevoelker.de>
vanstyn: Henry Van Styn <vanstyn@cpan.org>
victori: Victor Igumnov <victori@cpan.org>
wdh: Will Hawes <wdhawes@gmail.com>
wesm: Wes Malone <wes@mitsi.com>
Expand Down
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/DBIx/Class/ResultSet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
19 changes: 16 additions & 3 deletions xt/extra/internals/merge_joinpref_attr.t
Original file line number Diff line number Diff line change
Expand Up @@ -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' );

Expand Down Expand Up @@ -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;

0 comments on commit ca30d84

Please sign in to comment.