From fe546cb027a1604ce2ba0f93b1bd241794fb66e4 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 5 Aug 2013 10:22:35 +0200 Subject: [PATCH] ParseFilter: neuer Operator 'eq_ignore_empty' Ignoriert den Filter, wenn er leer ist. Andernfalls wird mit = verglichen. --- SL/Controller/Helper/ParseFilter.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SL/Controller/Helper/ParseFilter.pm b/SL/Controller/Helper/ParseFilter.pm index 1d0515cc8..db5940843 100644 --- a/SL/Controller/Helper/ParseFilter.pm +++ b/SL/Controller/Helper/ParseFilter.pm @@ -22,6 +22,7 @@ my %filters = ( my %methods = ( enable => sub { ;;;; }, + eq_ignore_empty => sub { ($_[0] // '') eq '' ? () : +{ eq => $_[0] } }, map { # since $_ is an alias it can't be used in a closure. even "".$_ or "$_" # does not work, we need a real copy. @@ -383,6 +384,11 @@ Adds "%" at the end of the string. Adds "% .. %" around the search string. +=item eq_ignore_empty + +Ignores this item if it's empty. Otherwise compares it with the +standard SQL C<=> operator. + =back =head2 METHODS (leading with ::) -- 2.20.1