From 945cd9362ec39f5c253aa9eda6aed3b8491abcd6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 4 Nov 2010 17:27:40 +0100 Subject: [PATCH] ParseFilter: Bugfix bei short circuit bedingung Test angepasst --- SL/Controller/Helper/ParseFilter.pm | 6 +++--- t/controllers/helpers/parse_filter.t | 10 +++------- 2 files changed, 6 insertions(+), 10 deletions(-) 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 { -- 2.20.1