From a615812c73cf5b07005b4f56aae5aa1da8357ee9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Mon, 15 Sep 2014 15:18:51 +0200 Subject: [PATCH] ParseFilter: with_objects merging bei Klassen mit Filtered Plugin MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ParseFilter kennt 3 Quellen für with_objects Klauseln: 1. explizit übergebene 2. aus dem Filter inferierte 3. aus custom filtern gesetzte Wenn nun ein Model das Custom Filter Plugin hat, muss bei jedem Filter getestet werden, ob dieser Filter eigene with_objects setzt oder nicht. Wenn der Filter aber auf eine normale Spalte zeigt, muss wie ohne Klasse auch der Standardpfad als Include gesetzt werden. Das war aber nicht der Fall. --- SL/Controller/Helper/ParseFilter.pm | 2 +- SL/DB/Helper/Filtered.pm | 4 ++-- t/controllers/helpers/parse_filter.t | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/SL/Controller/Helper/ParseFilter.pm b/SL/Controller/Helper/ParseFilter.pm index 308952b63..37b06737d 100644 --- a/SL/Controller/Helper/ParseFilter.pm +++ b/SL/Controller/Helper/ParseFilter.pm @@ -167,7 +167,7 @@ sub _dispatch_custom_filters { my $obj_prefix = join '.', @tokens, ''; if ($manager->can('filter')) { - ($key, $value, my $obj) = $manager->filter($last_token, $value, $obj_prefix); + ($key, $value, my $obj) = $manager->filter($last_token, $value, $obj_prefix, $obj_path); _add_uniq($with_objects, $obj) if $obj; } else { _add_uniq($with_objects, $obj_path) if $obj_path; diff --git a/SL/DB/Helper/Filtered.pm b/SL/DB/Helper/Filtered.pm index e95c01f05..0b2b473d8 100644 --- a/SL/DB/Helper/Filtered.pm +++ b/SL/DB/Helper/Filtered.pm @@ -10,11 +10,11 @@ our @EXPORT = qw (filter add_filter_specs); my %filter_spec; sub filter { - my ($class, $key, $value, $prefix) = @_; + my ($class, $key, $value, $prefix, $path) = @_; my $filters = _get_filters($class); - return ($prefix . $key, $value) unless $filters->{$key}; + return ($prefix . $key, $value, $path) unless $filters->{$key}; return $filters->{$key}->($key, $value, $prefix); } diff --git a/t/controllers/helpers/parse_filter.t b/t/controllers/helpers/parse_filter.t index 051134660..583b26cd3 100644 --- a/t/controllers/helpers/parse_filter.t +++ b/t/controllers/helpers/parse_filter.t @@ -291,7 +291,8 @@ test { 'part.partnumber', { ilike => '%1%' } - ] + ], + with_objects => [ 'part' ], }, 'Regression check: prefixing of fallback filtering in relation with custom filters', class => 'SL::DB::Manager::OrderItem'; test { 'description:substr:multi::ilike' => 'term1 term2', -- 2.20.1