Skip to content

Commit 95da0f2

Browse files
committed
One more fail-case missed in 135ac69
Now the test attached to RT#98161 actually passes... le sigh At this point I am very wary of the entire codepath: yes, it is clearly the right thing to do, and the logic is sound, but odd edge cases keep popping up like this... OTOH there is no way to properly do equality inferrence without this entire dance, in other words: rock&hardplace. Hopefully the test suites will shake this out, apologoies to all affected :(
1 parent ff7d03e commit 95da0f2

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/DBIx/Class/Storage/DBIHacks.pm

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,10 +1086,12 @@ sub _collapse_cond {
10861086
return unless $fin_idx;
10871087

10881088
$fin = ( keys %$fin_idx == 1 ) ? (values %$fin_idx)[0] : {
1089-
-or => [ map
1090-
{ ref $fin_idx->{$_} eq 'HASH' ? %{$fin_idx->{$_}} : $fin_idx->{$_} }
1091-
sort keys %$fin_idx
1092-
]
1089+
-or => [ map {
1090+
# unroll single-element hashes
1091+
( ref $fin_idx->{$_} eq 'HASH' and keys %{$fin_idx->{$_}} == 1 )
1092+
? %{$fin_idx->{$_}}
1093+
: $fin_idx->{$_}
1094+
} sort keys %$fin_idx ]
10931095
};
10941096
}
10951097
else {

t/sqlmaker/dbihacks_internals.t

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@ for my $t (
146146
},
147147

148148
) ),
149+
{
150+
where => { -or => [ -and => [ foo => { '!=', undef }, bar => { -in => [ 69, 42 ] } ], foo => { '=', { -value => undef } } ] },
151+
sql => 'WHERE ( foo IS NOT NULL AND bar IN ( ?, ? ) ) OR foo IS NULL',
152+
collapsed_sql => 'WHERE foo IS NULL OR ( bar IN ( ?, ? ) AND foo IS NOT NULL )',
153+
cc_result => { -or => [
154+
foo => undef,
155+
{ bar => { -in => [ 69, 42 ] }, foo => { '!=', undef } }
156+
] },
157+
efcc_result => {},
158+
},
149159
{
150160
where => { -or => [ rank => { '=' => \13 }, charfield => { '=' => undef }, artistid => { '=' => 1 }, genreid => { '=' => \['?', 2] } ] },
151161
sql => 'WHERE rank = 13 OR charfield IS NULL OR artistid = ? OR genreid = ?',

0 commit comments

Comments
 (0)