From: Peter Rabbitson Date: Fri, 2 Jan 2015 14:10:13 +0000 (+0100) Subject: Only normalize conditions during resolution time, instead on every ->search X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c9087040faf8de638936b163c20f702a2878d7ab;p=dbsrgits%2FDBIx-Class.git Only normalize conditions during resolution time, instead on every ->search The normalization operation isn't cheap. Should result in no changes. --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 97cfe50..1b35cf3 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -654,17 +654,15 @@ sub _stack_cond { (ref $_ eq 'HASH' and ! keys %$_) ) and $_ = undef for ($left, $right); - # either one of the two undef - if ( (defined $left) xor (defined $right) ) { - return defined $left ? $left : $right; - } - # both undef - elsif ( ! defined $left ) { - return undef - } - else { - return normalize_sqla_condition({ -and => [$left, $right] }); - } + return( + # either one of the two undef + ( (defined $left) xor (defined $right) ) ? ( defined $left ? $left : $right ) + + # both undef + : ( ! defined $left ) ? undef + + : { -and => [$left, $right] } + ); } =head2 search_literal @@ -3529,6 +3527,9 @@ sub _resolved_attrs { if ( $attrs->{rows} =~ /[^0-9]/ or $attrs->{rows} <= 0 ); } + # normalize where condition + $attrs->{where} = normalize_sqla_condition( $attrs->{where} ) + if $attrs->{where}; # default selection list $attrs->{columns} = [ $source->columns ] diff --git a/xt/extra/lean_startup.t b/xt/extra/lean_startup.t index 2731f0c..f915819 100644 --- a/xt/extra/lean_startup.t +++ b/xt/extra/lean_startup.t @@ -184,6 +184,7 @@ BEGIN { register_lazy_loadable_requires(qw( DBI Hash::Merge + Data::Dumper )); {