[ic] Search definition question. Data-format-induced craziness.

John Young interchange-users@icdevgroup.org
Tue Jun 25 14:35:01 2002


Martin Abell asked:

> I have a client who set up categories like:
>  Connectors 
>  Connectors-Audio
>  Connectors-RF
> 
> and so on.  Each has multiple subcategories.  The original code for pulling
> the subcategories out when a shopper clicked the category was:
>   [loop search="
>         st=sql
>         sf=category
>         se=[scratch catgy]
>         tf=subcategory
>         un=yes
>         rf=subcategory
>   "]
> 
> However, for the plain Connectors category, it retrieved the subcategories
> for all categories beginning with "Connectors".  I tried every combination
> of search term, e.g., op=em (or op=eq em=yes - whichever it is) and ac=1 and
> so on and on and on.  Nothing worked.


Not sure if this is the same situation or not, but there was an obscure
problem that Mike fixed back in February.  The fix is in any post-4.8.3
code, I believe in Vend/Search.pm.  You might wish to try upgrading
to 4.8.5 (there are some other good reasons for doing this) if at all possible.
I can't seem to locate this in the archives, so I am attaching Mike's two replies:

> Date: Tue, 5 Feb 2002 22:18:09 -0500
> From: Mike Heins <mheins@redhat.com>
> To: interchange-users@interchange.redhat.com
> Subject: Re: [ic] Need exact matches in category not substring (WHERE = vs. WHERE LIKE %%)
> Reply-To: interchange-users@interchange.redhat.com
> 
> Quoting John Young (john_young@sonic.net):

> Hi, everyone.
> 
> If one were to take the Foundation demo with IC 4.8.3 using MySQL 3.23.44
> (SQLDSN  dbi:mysql:dbname / perl 5.6.1 / Linux 2.4.10)
> and add categories such that one had category names like:
> 
> Metal
> Metal Discs
> 
> How does one avoid having both categories display when only
> "Metal" is selected?
> 
> 
> Essentially, I want results just like you would get from:
> 
> SELECT title FROM products WHERE category = "Metal";
> 
> but instead I am getting results like you would get from:
> 
> SELECT title FROM products WHERE category LIKE "%Metal%";
> 
> when using the default link from [cat-exec bar_link]cat[/cat-exec]
> in foundation/templates/components/category_vertical.

You have found a bug, thank you!

A workaround is to use this for now:

        [page  href=scan
                arg="
                        co=yes
                        st=db

                        sf=category
                        op=em
                        se=Metal

                        os=yes

                "]try it</A>

The os=yes avoids the false filter function which is getting done, even
though there is nothing to OR.

The real fix is this patch to lib/Vend/Search.pm:

--- /tmp/Search.pm      Tue Feb  5 22:12:40 2002
+++ lib/Vend/Search.pm  Tue Feb  5 22:14:38 2002
@@ -255,9 +255,9 @@
                                if(     $s->{mv_column_op}[$i] =~ /([=][~]|rm|em)/ ) {
                                        $specs[$i] = quotemeta $specs[$i]
                                                if $s->{mv_all_chars}[$i];
-                                       $s->{regex_specs} = []
-                                               unless $s->{regex_specs};
                                        last COLOP if $s->{mv_begin_string}[$i];
+                                       last COLOP if $s->{mv_column_op}[$i] eq 'em';
+                                       $s->{regex_specs} ||= [];
                                        $specs[$i] =~ /(.*)/;
                                        push @{$s->{regex_specs}}, $1
                                }
@@ -716,6 +716,7 @@
 #::logDebug("coderef=" . ::uneval_it(\@code));
 
                undef $f if $s->{mv_search_relate} =~ s/\bor\b/or/ig;
+               undef $f unless $s->{regex_specs} or $s->{eq_specs};
                DOLIMIT: {
 #::logDebug(::uneval_it({%$s}));
 #::logDebug("do_limit.");

-- 
Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH  45013
phone +1.513.523.7621      <mheins@redhat.com>

Prove you aren't stupid.  Say NO to Passport.

--__--__--





Message: 35
Date: Tue, 5 Feb 2002 22:41:24 -0500
From: Mike Heins <mheins@redhat.com>
To: interchange-users@interchange.redhat.com
Subject: Re: [ic] Need exact matches in category not substring (WHERE = vs. WHERE LIKE %%)
Reply-To: interchange-users@interchange.redhat.com

Quoting Mike Heins (mheins@redhat.com):
> The real fix is this patch to lib/Vend/Search.pm:

That won't be the real fix -- it has a bit of duplicated code. I am testing
and committing the real patch to CVS as I write.

-- 
Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH  45013
phone +1.513.523.7621      <mheins@redhat.com>

Experience is what allows you to recognize a mistake the second
time you make it. -- unknown

--__--__--