From: Sven Schöling Date: Thu, 22 Dec 2011 11:41:15 +0000 (+0100) Subject: Bei tiefen parse_filters with_objects mit prefix bauen. X-Git-Tag: release-2.7.0beta1~105 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=39556a0d83b35291fec9a17cd14762232ae008d7;p=kivitendo-erp.git Bei tiefen parse_filters with_objects mit prefix bauen. --- diff --git a/SL/Controller/Helper/ParseFilter.pm b/SL/Controller/Helper/ParseFilter.pm index ac086f594..7c393b01c 100644 --- a/SL/Controller/Helper/ParseFilter.pm +++ b/SL/Controller/Helper/ParseFilter.pm @@ -74,7 +74,7 @@ sub _pre_parse { if ('HASH' eq ref $value) { my ($query, $more_objects) = _pre_parse($value, $with_objects, _prefix($prefix, $key)); push @result, @$query if $query; - push @$with_objects, $key, ($more_objects ? @$more_objects : ()); + push @$with_objects, _prefix($prefix, $key), ($more_objects ? @$more_objects : ()); } else { push @result, _prefix($prefix, $key) => $value; } diff --git a/t/controllers/helpers/parse_filter.t b/t/controllers/helpers/parse_filter.t index 198877358..554985d92 100644 --- a/t/controllers/helpers/parse_filter.t +++ b/t/controllers/helpers/parse_filter.t @@ -58,7 +58,7 @@ test { } }, { query => [ 'customer.chart.accno' => 'test' ], - with_objects => bag( 'customer', 'chart' ), + with_objects => bag( 'customer', 'customer.chart' ), }, 'nested joins'; test { @@ -82,7 +82,7 @@ test { }, { query => [ 'customer.chart.accno' => { like => '%1200' } ], - with_objects => bag('customer', 'chart' ), + with_objects => bag('customer', 'customer.chart' ), }, 'all together'; @@ -100,7 +100,7 @@ test { 'invoice.customer.name' => 'test', 'customer.name' => 'test', }} ], - 'with_objects' => bag( 'invoice', 'customer' ) + 'with_objects' => bag( 'invoice.customer', 'customer', 'invoice' ) }, 'object in more than one relationship'; test { @@ -177,3 +177,16 @@ test { } }, 'deep laundering, check for laundered hash', target => 'launder', launder_to => { }; +### bug: sub objects + +test { + order => { + customer => { + 'name:substr::ilike' => 'test', + } + } +}, { + query => [ 'order.customer.name' => { ilike => '%test%' } ], + with_objects => bag('order.customer', 'order'), +}, 'sub objects have to retain their prefix'; +