X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fsearch%2Fstack_cond.t;h=6989c6fddafebf447bd354633ab04163b073ef45;hb=d6c13bfdf6656317fedbf7e9deeb450cf42efb5b;hp=a68f6922670f5d6a185c2425ebd0c23aa3491bfa;hpb=5268b1da661134493695d0c8f364b2d094da616e;p=dbsrgits%2FDBIx-Class.git diff --git a/t/search/stack_cond.t b/t/search/stack_cond.t index a68f692..6989c6f 100644 --- a/t/search/stack_cond.t +++ b/t/search/stack_cond.t @@ -1,14 +1,14 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } + use strict; use warnings; use Test::More; -use lib qw(t/lib); + +use DBIx::Class::_Util 'dump_value'; use DBICTest ':DiffSQL'; use SQL::Abstract qw(is_plain_value is_literal_value); use List::Util 'shuffle'; -use Data::Dumper; -$Data::Dumper::Terse = 1; -$Data::Dumper::Useqq = 1; $Data::Dumper::Indent = 0; my $schema = DBICTest->init_schema(); @@ -35,8 +35,10 @@ for my $c ( my $bare_cond = is_literal_value($c->{cond}) ? { '=', $c->{cond} } : $c->{cond}; my @query_steps = ( - # this is a monkey-wrench, always there + # these are monkey-wrenches, always there { title => { '!=', [ -and => \'bar' ] }, year => { '!=', [ -and => 'bar' ] } }, + { -or => [ genreid => undef, genreid => { '!=' => \42 } ] }, + { -or => [ genreid => undef, genreid => { '!=' => \42 } ] }, { title => $bare_cond, year => { '=', $c->{cond} } }, { -and => [ year => $bare_cond, { title => { '=', $c->{cond} } } ] }, @@ -48,9 +50,9 @@ for my $c ( if (my $v = is_plain_value($c->{cond})) { push @query_steps, - { year => $v->[0] }, - { title => $v->[0] }, - { -and => [ year => $v->[0], title => $v->[0] ] }, + { year => $$v }, + { title => $$v }, + { -and => [ year => $$v, title => $$v ] }, ; } @@ -69,10 +71,19 @@ for my $c ( "( SELECT me.title FROM cd me - WHERE title != bar AND title $c->{sql} AND year != ? AND year $c->{sql} + WHERE + ( genreid IS NULL OR genreid != 42 ) + AND + title != bar + AND + title $c->{sql} + AND + year != ? + AND + year $c->{sql} )", \@bind, - 'Double condition correctly collapsed for steps' . Dumper \@query_steps, + 'Double condition correctly collapsed for steps:' . join( '', map { "\n\t" . dump_value($_) } @query_steps ), ); }