Skip Menu |

This queue is for tickets about the SQL-Statement CPAN distribution.

Report information
The Basics
Id: 6596
Status: resolved
Priority: 0/
Queue: SQL-Statement

People
Owner: JZUCKER [...] cpan.org
Requestors: cpan [...] goess.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.09
Fixed in: (no value)



Subject: parens not parsing
Hi there. It looks like SQL::Statement doesn't parse properly if the parenthesized OR statement contains a comparison to an empty string. The SQL below should parse, and does parse if you switch the order of the clauses around. The problem looks like it's the regex in clean_sql() at line 1744, but that's all I can tell. Details: SQL-Statement-1.09 perl 5.8.0 Linux straylight.ensenda.com 2.4.18 #1 SMP Thu Mar 28 09:24:05 PST 2002 i686 unknown Red Hat Linux release 7.2 (Enigma) Error message: SQL ERROR: Mismatched parentheses in WHERE clause! Code to Reproduce: $stmt = <<EOL; select col1, col2, col3 from mytable where col1 = ? AND (col2 = 'foo' OR col2 = '') AND col3 = 'bar' EOL $stmt = SQL::Statement->new($stmt); Thanks.
From: cpan [...] goess.org
Actually, I think you can fix it by changing the regex to this $sql =~ s~(?<!')'(([^'$e]|$e.|'')+)'~push(@$fields,$1);$i++;"?$i?"~ge; the (?<!') will keep the regex from thinking the second ' in an empty '' is the beginning of a field value.
Ah, excellent, thanks. The patch and credit to you will be included in version 1.10.