From: Sven Schöling Date: Thu, 4 Nov 2010 16:27:40 +0000 (+0100) Subject: ParseFilter: Bugfix bei short circuit bedingung X-Git-Tag: release-2.7.0beta1~203 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=945cd9362ec39f5c253aa9eda6aed3b8491abcd6;p=kivitendo-erp.git ParseFilter: Bugfix bei short circuit bedingung Test angepasst --- diff --git a/SL/Controller/Helper/ParseFilter.pm b/SL/Controller/Helper/ParseFilter.pm index 96d3b3296..b7769bb8a 100644 --- a/SL/Controller/Helper/ParseFilter.pm +++ b/SL/Controller/Helper/ParseFilter.pm @@ -39,8 +39,8 @@ sub parse_filter { _launder_keys($filter) unless $params{no_launder}; return - query => $query, - @$objects ? ( with_objects => [ uniq @$objects ]) : (); + ($query && @$query ? (query => $query) : ()), + ($objects && @$objects ? ( with_objects => [ uniq @$objects ]) : ()); } sub _launder_keys { @@ -61,7 +61,7 @@ sub _pre_parse { my ($filter, $with_objects, $prefix, %params) = @_; return () unless 'HASH' eq ref $filter; - $with_objects = []; + $with_objects ||= []; my @result; diff --git a/t/controllers/helpers/parse_filter.t b/t/controllers/helpers/parse_filter.t index 5a1ca0728..03d5d1514 100644 --- a/t/controllers/helpers/parse_filter.t +++ b/t/controllers/helpers/parse_filter.t @@ -22,7 +22,6 @@ sub test ($$$) { } test { }, { - query => [] }, 'minimal test'; test { @@ -52,7 +51,7 @@ test { } }, { query => [ 'customer.chart.accno' => 'test' ], - with_objects => [ 'customer', 'chart' ], + with_objects => bag( 'customer', 'chart' ), }, 'nested joins'; test { @@ -76,7 +75,7 @@ test { }, { query => [ 'customer.chart.accno' => { like => '%1200' } ], - with_objects => ['customer', 'chart' ], + with_objects => bag('customer', 'chart' ), }, 'all together'; @@ -94,10 +93,7 @@ test { 'invoice.customer.name' => 'test', 'customer.name' => 'test', }} ], - 'with_objects' => [ - 'invoice', - 'customer' - ] + 'with_objects' => bag( 'invoice', 'customer' ) }, 'object in more than one relationship'; test {