[open-ils-commits] r19926 - in branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Storage: . Driver/Pg (dbwells)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Apr 1 11:18:39 EDT 2011


Author: dbwells
Date: 2011-04-01 11:18:36 -0400 (Fri, 01 Apr 2011)
New Revision: 19926

Modified:
   branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
   branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Storage/QueryParser.pm
Log:
Better search normalization de-duping when 'params' are used

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).


Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm	2011-04-01 15:18:10 UTC (rev 19925)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm	2011-04-01 15:18:36 UTC (rev 19926)
@@ -750,8 +750,9 @@
         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};
                     }
                 }
             }

Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Storage/QueryParser.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Storage/QueryParser.pm	2011-04-01 15:18:10 UTC (rev 19925)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Storage/QueryParser.pm	2011-04-01 15:18:36 UTC (rev 19926)
@@ -1,4 +1,5 @@
 package QueryParser;
+use OpenSRF::Utils::JSON;
 our %parser_config = (
     QueryParser => {
         filters => [],
@@ -180,7 +181,11 @@
     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 });
 



More information about the open-ils-commits mailing list