[ic] SQL_Parser.pm

Quoting Stefan Hornburg (Racke) (racke at linuxia.de):
> On Mon, 26 Jan 2004 12:48:15 -0500
> Mike Heins <mike at perusion.com> wrote:
>> > Quoting Sandy Thomson (sandy at scotwebshops.com):
> > > Hi,
> > > I have been attempting to upgrade some of our shops to IC 5.0.0. However
> > > in doing so I have encountered issues with a new file called SQL_Parser.pm.
> > >
> > > The version we are moving from is a cvs build of 4.8.7, and this does
> > > not seem to have this perl module in lib/Vend, so I assume pre 5.0.0
> > > interchange versions dealt with search tag expansion differently?
> > >
> > > The errors I have been encountering are of the form:
> > > x.x.x.x session_id:nobody - [26/January/2004:11:19:13 +0000] site
> > > www.site.com/sku_item SQL query failed: syntax error: unknown op
> > > 'o_sort' at /home/shops/interchange-5.0/lib/Vend/SQL_Parser.pm line 447.
> > > >
> > > > query was: SELECT code,o_group,o_value,o_label,o_widget,price FROM
> > > options where sku = 'sku_item'ORDER BY o_sort
> > >
> > > The errors have been occuring whenever a page with product options is
> > > requested. I assume it is just an issue with interchange 5 (or our sites)?
> > >
> > > Any hints?
> >
> > Vend::SQL_Parser replaces SQL::Statement.
> >
> > I don't see how anyone could figure out what is going on without
> > seeing what you have in the failing page.
> >
> > >From the error I see, assuming it is put in there properly (doubtful
> > because it is wrapped) it looks like there is an incorrectly formattted
> > query. But without seeing what generates it there is no way to tell.
>> But there is code in Options/Old48.pm which would generate a query without
> a space between ' and ORDER BY:
>> my $q = "SELECT " . join (",", @rf) . " FROM $tname where $fsel = $rsel";
>> if(my $rsort = find_sort($opt)) {
> $q .= $rsort;
> }
>> I don't know what the SQL standard says, but MySQL parses this query while
> SQL_Parser obviously doesn't.
It cannot be valid, I don't think, unless a single-quote by definition
always terminates a field.
If that is the source of the problem, we just need:
if(my $rsort = find_sort($opt)) {
$rsort =~ s/^\s*/ /;
$q .= $rsort;
}
--
Mike Heins
Perusion -- Expert Interchange Consulting http://www.perusion.com/
phone +1.765.647.1295 tollfree 800-949-1889 <mike at perusion.com>
I have a cop friend who thinks he ought be able to give a new ticket;
"too dumb for conditions".