X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fresultset%2Frowparser_internals.t;fp=t%2Fresultset%2Frowparser_internals.t;h=2c593e751f3664840bebcabb7b1c3da61676d436;hb=b3a400a044a5e4a768e26d450e3cce289481ee7a;hp=d83a685f8fdc68ae71bb35566e28cfba2c6c39b7;hpb=5ff6d6034ddcb696d24c4b716b5c12f109004d1f;p=dbsrgits%2FDBIx-Class.git diff --git a/t/resultset/rowparser_internals.t b/t/resultset/rowparser_internals.t index d83a685..2c593e7 100644 --- a/t/resultset/rowparser_internals.t +++ b/t/resultset/rowparser_internals.t @@ -259,6 +259,40 @@ is_same_src ( ( $_[1] and $_[1]->() ) ) ) { + + # NULL checks + # mandatory => { 4 => 1, 5 => 1 } + # from_first_encounter => [ [ 1, 3, 0 ] ] + # + ( defined( $cur_row_data->[4] ) or $_[3]->{4} = 1 ), + + ( defined( $cur_row_data->[5] ) or $_[3]->{5} = 1 ), + + ( + ( not defined $cur_row_data->[1] ) + ? ( + ( not defined $cur_row_data->[3] ) + and + ( not defined $cur_row_data->[0] ) + or + ( $_[3]->{1} = 1 ) + ) + : ( not defined $cur_row_data->[3] ) + ? ( + ( not defined $cur_row_data->[0] ) + or + ( $_[3]->{3} = 1 ) + ) + : () + ), + + ( keys %{$_[3]} and ( + ( @{$_[2]} = $cur_row_data ), + ( $result_pos = 0 ), + last + ) ), + + ( @cur_row_ids{0,1,3,4,5} = ( ( $cur_row_data->[0] // "\0NULL\xFF$rows_pos\xFF0\0" ), ( $cur_row_data->[1] // "\0NULL\xFF$rows_pos\xFF1\0" ), @@ -333,6 +367,40 @@ is_same_src ( ( $_[1] and $_[1]->() ) ) ) { + + # NULL checks + # mandatory => { 4 => 1, 5 => 1 } + # from_first_encounter => [ [ 1, 3, 0 ] ] + # + ( defined( $cur_row_data->[4] ) or $_[3]->{4} = 1 ), + + ( defined( $cur_row_data->[5] ) or $_[3]->{5} = 1 ), + + ( + ( not defined $cur_row_data->[1] ) + ? ( + ( not defined $cur_row_data->[3] ) + and + ( not defined $cur_row_data->[0] ) + or + ( $_[3]->{1} = 1 ) + ) + : ( not defined $cur_row_data->[3] ) + ? ( + ( not defined $cur_row_data->[0] ) + or + ( $_[3]->{3} = 1 ) + ) + : () + ), + + ( keys %{$_[3]} and ( + ( @{$_[2]} = $cur_row_data ), + ( $result_pos = 0 ), + last + ) ), + + ( @cur_row_ids{0, 1, 3, 4, 5} = @{$cur_row_data}[0, 1, 3, 4, 5] ), # a present cref in $_[1] implies lazy prefetch, implies a supplied stash in $_[2] @@ -464,6 +532,48 @@ is_same_src ( ( $_[1] and $_[1]->() ) ) ) { + + # NULL checks + # mandatory => { 1 => 1 } + # from_first_encounter => [ [6, 8], [5, 10, 0] ], + # + ( defined( $cur_row_data->[1] ) or $_[3]->{1} = 1 ), + + ( + ( not defined $cur_row_data->[6] ) + ? ( + ( not defined $cur_row_data->[8] ) + or + ( $_[3]->{6} = 1 ) + ) + : () + ), + + ( + ( not defined $cur_row_data->[5] ) + ? ( + ( not defined $cur_row_data->[10] ) + and + ( not defined $cur_row_data->[0] ) + or + ( $_[3]->{5} = 1 ) + ) + : ( not defined $cur_row_data->[10] ) + ? ( + ( not defined $cur_row_data->[0] ) + or + ( $_[3]->{10} = 1 ) + ) + : () + ), + + ( keys %{$_[3]} and ( + ( @{$_[2]} = $cur_row_data ), + ( $result_pos = 0 ), + last + ) ), + + ( @cur_row_ids{0, 1, 5, 6, 8, 10} = ( $cur_row_data->[0] // "\0NULL\xFF$rows_pos\xFF0\0", $cur_row_data->[1], @@ -549,6 +659,48 @@ is_same_src ( ( $_[1] and $_[1]->() ) ) ) { + + # NULL checks + # mandatory => { 1 => 1 } + # from_first_encounter => [ [6, 8], [5, 10, 0] ], + # + ( defined( $cur_row_data->[1] ) or $_[3]->{1} = 1 ), + + ( + ( not defined $cur_row_data->[6] ) + ? ( + ( not defined $cur_row_data->[8] ) + or + ( $_[3]->{6} = 1 ) + ) + : () + ), + + ( + ( not defined $cur_row_data->[5] ) + ? ( + ( not defined $cur_row_data->[10] ) + and + ( not defined $cur_row_data->[0] ) + or + ( $_[3]->{5} = 1 ) + ) + : ( not defined $cur_row_data->[10] ) + ? ( + ( not defined $cur_row_data->[0] ) + or + ( $_[3]->{10} = 1 ) + ) + : () + ), + + ( keys %{$_[3]} and ( + ( @{$_[2]} = $cur_row_data ), + ( $result_pos = 0 ), + last + ) ), + + ( @cur_row_ids{( 0, 1, 5, 6, 8, 10 )} = @{$cur_row_data}[( 0, 1, 5, 6, 8, 10 )] ), # a present cref in $_[1] implies lazy prefetch, implies a supplied stash in $_[2] @@ -680,6 +832,49 @@ is_same_src ( ( $_[1] and $_[1]->() ) ) ) { + + # NULL checks + # + # from_first_encounter => [ [0, 4, 8] ] + # all_or_nothing => [ { 2 => 1, 3 => 1 } ] + ( + ( not defined $cur_row_data->[0] ) + ? ( + ( not defined $cur_row_data->[4] ) + and + ( not defined $cur_row_data->[8] ) + or + ( $_[3]->{0} = 1 ) + ) + : ( not defined $cur_row_data->[4] ) + ? ( + ( not defined $cur_row_data->[8] ) + or + ( $_[3]->{4} = 1 ) + ) + : () + ), + + ( + ( + ( not defined $cur_row_data->[2] ) + and + ( not defined $cur_row_data->[3] ) + ) + or + ( + ( defined($cur_row_data->[2]) or $_[3]->{2} = 1 ), + ( defined($cur_row_data->[3]) or $_[3]->{3} = 1 ), + ) + ), + + ( keys %{$_[3]} and ( + ( @{$_[2]} = $cur_row_data ), + ( $result_pos = 0 ), + last + ) ), + + ( @cur_row_ids{( 0, 2, 3, 4, 8 )} = ( $cur_row_data->[0] // "\0NULL\xFF$rows_pos\xFF0\0", $cur_row_data->[2] // "\0NULL\xFF$rows_pos\xFF2\0", @@ -766,6 +961,49 @@ is_same_src ( ( $_[1] and $_[1]->() ) ) ) { + + # NULL checks + # + # from_first_encounter => [ [0, 4, 8] ] + # all_or_nothing => [ { 2 => 1, 3 => 1 } ] + ( + ( not defined $cur_row_data->[0] ) + ? ( + ( not defined $cur_row_data->[4] ) + and + ( not defined $cur_row_data->[8] ) + or + ( $_[3]->{0} = 1 ) + ) + : ( not defined $cur_row_data->[4] ) + ? ( + ( not defined $cur_row_data->[8] ) + or + ( $_[3]->{4} = 1 ) + ) + : () + ), + + ( + ( + ( not defined $cur_row_data->[2] ) + and + ( not defined $cur_row_data->[3] ) + ) + or + ( + ( defined($cur_row_data->[2]) or $_[3]->{2} = 1 ), + ( defined($cur_row_data->[3]) or $_[3]->{3} = 1 ), + ) + ), + + ( keys %{$_[3]} and ( + ( @{$_[2]} = $cur_row_data ), + ( $result_pos = 0 ), + last + ) ), + + # do not care about nullability here ( @cur_row_ids{( 0, 2, 3, 4, 8 )} = @{$cur_row_data}[( 0, 2, 3, 4, 8 )] ), @@ -911,6 +1149,66 @@ is_same_src ( ( $_[1] and $_[1]->() ) ) ) { + # NULL checks + # + # from_first_encounter => [ [6, 4, 8], [6, 0, 9] ] + # all_or_nothing => [ { 2 => 1, 3 => 1 } ] + ( + ( not defined $cur_row_data->[6] ) + ? ( + ( not defined $cur_row_data->[4] ) + and + ( not defined $cur_row_data->[8] ) + or + ( $_[3]->{6} = 1 ) + ) + : ( not defined $cur_row_data->[4] ) + ? ( + ( not defined $cur_row_data->[8] ) + or + ( $_[3]->{4} = 1 ) + ) + : () + ), + + ( + ( not defined $cur_row_data->[6] ) + ? ( + ( not defined $cur_row_data->[0] ) + and + ( not defined $cur_row_data->[9] ) + or + ( $_[3]->{6} = 1 ) + ) + : ( not defined $cur_row_data->[0] ) + ? ( + ( not defined $cur_row_data->[9] ) + or + ( $_[3]->{0} = 1 ) + ) + : () + ), + + ( + ( + ( not defined $cur_row_data->[2] ) + and + ( not defined $cur_row_data->[3] ) + ) + or + ( + ( defined($cur_row_data->[2]) or $_[3]->{2} = 1 ), + ( defined($cur_row_data->[3]) or $_[3]->{3} = 1 ), + ) + ), + + ( keys %{$_[3]} and ( + ( @{$_[2]} = $cur_row_data ), + ( $result_pos = 0 ), + last + ) ), + + # do not care about nullability here ( @cur_row_ids{( 0, 2, 3, 4, 6, 8, 9 )} = @{$cur_row_data}[( 0, 2, 3, 4, 6, 8, 9 )] ), @@ -1037,6 +1335,110 @@ is_same_src ( 'Non-premultiplied implicit collapse with missing join columns', ); +is_same_src ( + ($schema->source('Artist')->_mk_row_parser({ + inflate_map => [qw( artistid cds.artist cds.title cds.tracks.title )], + collapse => 1, + prune_null_branches => 1, + }))[0], + ' my $rows_pos = 0; + my ($result_pos, @collapse_idx, $cur_row_data, %cur_row_ids ); + + while ($cur_row_data = ( + ( + $rows_pos >= 0 + and + ( + $_[0][$rows_pos++] + or + ( ($rows_pos = -1), undef ) + ) + ) + or + ( $_[1] and $_[1]->() ) + ) ) { + + # NULL checks + # + # mandatory => { 0 => 1 } + # from_first_encounter => [ [1, 2, 3] ] + # all_or_nothing => [ { 1 => 1, 2 => 1 } ] + + ( defined( $cur_row_data->[0] ) or $_[3]->{0} = 1 ), + + ( + ( not defined $cur_row_data->[1] ) + ? ( + ( not defined $cur_row_data->[2] ) + and + ( not defined $cur_row_data->[3] ) + or + $_[3]->{1} = 1 + ) + : ( not defined $cur_row_data->[2] ) + ? ( + ( not defined $cur_row_data->[3] ) + or + $_[3]->{2} = 1 + ) + : () + ), + + ( + ( + ( not defined $cur_row_data->[1] ) + and + ( not defined $cur_row_data->[2] ) + ) + or + ( + ( defined($cur_row_data->[1]) or $_[3]->{1} = 1 ), + ( defined($cur_row_data->[2]) or $_[3]->{2} = 1 ), + ) + ), + + ( keys %{$_[3]} and ( + ( @{$_[2]} = $cur_row_data ), + ( $result_pos = 0 ), + last + ) ), + + + ( @cur_row_ids{( 0, 1, 2, 3 )} = @{$cur_row_data}[ 0, 1, 2, 3 ] ), + + ( $_[1] and $result_pos and ! $collapse_idx[0]{$cur_row_ids{0}} and (unshift @{$_[2]}, $cur_row_data) and last ), + + ( $collapse_idx[0]{ $cur_row_ids{0} } + //= $_[0][$result_pos++] = [ { "artistid" => $cur_row_data->[0] } ] + ), + + ( ( ! defined $cur_row_data->[1] ) ? $collapse_idx[0]{ $cur_row_ids{0} }[1]{"cds"} = [] : do { + + ( + ! $collapse_idx[1]{ $cur_row_ids{0} }{ $cur_row_ids{1} }{ $cur_row_ids{2} } + and + push @{$collapse_idx[0]{ $cur_row_ids{0} }[1]{"cds"}}, + $collapse_idx[1]{ $cur_row_ids{0} }{ $cur_row_ids{1} }{ $cur_row_ids{2} } + = [ { "artist" => $cur_row_data->[1], "title" => $cur_row_data->[2] } ] + ), + + ( ( ! defined $cur_row_data->[3] ) ? $collapse_idx[1]{ $cur_row_ids{0} }{ $cur_row_ids{1} }{ $cur_row_ids{2} }[1]{"tracks"} = [] : do { + ( + ! $collapse_idx[2]{ $cur_row_ids{0} }{ $cur_row_ids{1} }{ $cur_row_ids{2} }{ $cur_row_ids{3} } + and + push @{$collapse_idx[1]{ $cur_row_ids{0} }{ $cur_row_ids{1} }{ $cur_row_ids{2} }[1]{"tracks"}}, + $collapse_idx[2]{ $cur_row_ids{0} }{ $cur_row_ids{1} }{ $cur_row_ids{2} }{ $cur_row_ids{3} } + = [ { "title" => $cur_row_data->[3] } ] + ), + } ), + } ), + } + + $#{$_[0]} = $result_pos - 1 + ', + 'A rolled out version of inflate map of misled_rowparser.t' +); + done_testing; my $deparser;