From 39556a0d83b35291fec9a17cd14762232ae008d7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 22 Dec 2011 12:41:15 +0100 Subject: [PATCH] Bei tiefen parse_filters with_objects mit prefix bauen. --- SL/Controller/Helper/ParseFilter.pm | 2 +- t/controllers/helpers/parse_filter.t | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) 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'; + -- 2.20.1