[interchange] Don't try to optimize an or search where we don't have all the sql specs.

Peter Ajamian interchange-cvs at icdevgroup.org
Thu Dec 30 17:01:03 UTC 2010


commit e451273db0c79f9b605e6584c7749cb16599739e
Author: Peter Ajamian <peter at pajamian.dhs.org>
Date:   Fri Dec 31 05:55:18 2010 +1300

    Don't try to optimize an or search where we don't have all the sql specs.
    
    If we are running an or search and not all of the specs have equivelant sql
    specs (WHERE clauses) then don't try to optimize the query as doing so will
    cause records to not be returned that might match other specs.

 lib/Vend/Search.pm |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/lib/Vend/Search.pm b/lib/Vend/Search.pm
index f8aceea..53762f3 100644
--- a/lib/Vend/Search.pm
+++ b/lib/Vend/Search.pm
@@ -307,6 +307,18 @@ sub spec_check {
 		}
 	}
 
+        # If this is an or search and we don't have sql specs for *all* the
+	# specs then dump them alltogether otherwise we end up pre-emptively
+	# removing rows that may need to be in the results.
+        if (
+	    $s->{mv_orsearch} &&
+	    $s->{eq_specs_sql} &&
+	    @{$s->{eq_specs_sql}} &&
+	    @{$s->{eq_specs_sql}} < @specs
+	    ) {
+            delete $s->{eq_specs_sql};
+        }
+
 #::logDebug("regex_specs=" . ::uneval($s->{regex_specs}));
 #::logDebug("eq_specs_sql=" . ::uneval($s->{eq_specs_sql}));
 



More information about the interchange-cvs mailing list