This patch addresses search normalization deduping at two levels. We now verify that both the function and the params are the same before excluding a normalization, both when the normalization is first added to the set and when the SQL is being built (since currently multiple sets may be involved).
git-svn-id: svn://svn.open-ils.org/ILS/trunk@19924
dcc99617-32d9-48b4-a31d-
7c20da2025e4
for my $nfield (keys %$normalizers) {
for my $nizer ( @{$$normalizers{$nfield}} ) {
if ($field eq $nfield) {
- if (!exists($norms{$nizer->{function}})) {
- $norms{$nizer->{function}} = {p=>$pos++,n=>$nizer};
+ my $param_string = OpenSRF::Utils::JSON->perl2JSON($nizer->{params});
+ if (!exists($norms{$nizer->{function}.$param_string})) {
+ $norms{$nizer->{function}.$param_string} = {p=>$pos++,n=>$nizer};
}
}
}
package QueryParser;
+use OpenSRF::Utils::JSON;
our %parser_config = (
QueryParser => {
filters => [],
my $func = shift;
my $params = shift || [];
- return $func if (grep { $_ eq $func } @{$pkg->query_normalizers->{$class}->{$field}});
+ # do not add if function AND params are identical to existing member
+ return $func if (grep {
+ $_->{function} eq $func and
+ OpenSRF::Utils::JSON->perl2JSON($_->{params}) eq OpenSRF::Utils::JSON->perl2JSON($params)
+ } @{$pkg->query_normalizers->{$class}->{$field}});
push(@{$pkg->query_normalizers->{$class}->{$field}}, { function => $func, params => $params });