From: Peter Rabbitson Date: Tue, 19 Feb 2013 20:57:13 +0000 (+0100) Subject: Fatalize warnings within the compiled row parsers X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bdbd2ae8a0625e196ae820f85427d13629322c96;p=dbsrgits%2FDBIx-Class-Historic.git Fatalize warnings within the compiled row parsers Encountering an undef value anywhere in this code is a sign of some glaring omission. Perhaps a nullable column is annotated as is_nullable => 0 or something similar. When this is the case we need the collapsing to stop right there, as it is no longer safe to proceed. --- diff --git a/lib/DBIx/Class/ResultSource/RowParser.pm b/lib/DBIx/Class/ResultSource/RowParser.pm index 5b970d0..695736e 100644 --- a/lib/DBIx/Class/ResultSource/RowParser.pm +++ b/lib/DBIx/Class/ResultSource/RowParser.pm @@ -133,7 +133,7 @@ sub _mk_row_parser { } return $args->{eval} - ? ( eval "sub { $src }" || die $@ ) + ? ( eval "sub $src" || die $@ ) : $src ; } diff --git a/lib/DBIx/Class/ResultSource/RowParser/Util.pm b/lib/DBIx/Class/ResultSource/RowParser/Util.pm index 7e40b5c..48d2b08 100644 --- a/lib/DBIx/Class/ResultSource/RowParser/Util.pm +++ b/lib/DBIx/Class/ResultSource/RowParser/Util.pm @@ -33,7 +33,7 @@ sub assemble_simple_parser { # change the quoted placeholders to unquoted alias-references $parser_src =~ s/ \' \xFF__VALPOS__(\d+)__\xFF \' /"\$_->[$1]"/gex; - return $parser_src; + $parser_src = " { use strict; use warnings FATAL => 'all';\n$parser_src\n }"; } # the simple non-collapsing nested structure recursor @@ -191,7 +191,7 @@ EOS $parser_src =~ s/ \' \xFF__VALPOS__(\d+)__\xFF \' /"\$cur_row_data->[$1]"/gex; $parser_src =~ s/ \' \xFF__IDVALPOS__(\d+)__\xFF \' /"\$cur_row_ids{$1}"/gex; - $parser_src; + $parser_src = " { use strict; use warnings FATAL => 'all';\n$parser_src\n }"; } diff --git a/t/resultset/rowparser_internals.t b/t/resultset/rowparser_internals.t index ddebcc4..1317bb3 100644 --- a/t/resultset/rowparser_internals.t +++ b/t/resultset/rowparser_internals.t @@ -720,6 +720,8 @@ sub is_same_src { $expect =~ s/__NBC__/B::perlstring($DBIx::Class::ResultSource::RowParser::Util::null_branch_class)/ge; + $expect = " { use strict; use warnings FATAL => 'all';\n$expect\n }"; + my @normalized = map { my $cref = eval "sub { $_ }" or do { fail "Coderef does not compile!\n\n$@\n\n$_";