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

Peter Ajamian <[email protected]>
Newsgroups gmane.comp.web.interchange.cvs
Message-ID <[email protected]>
commit e451273db0c79f9b605e6584c7749cb16599739e
Author: Peter Ajamian <[email protected]>
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}));
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.