Skip Menu |

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

Report information
The Basics
Id: 107129
Status: open
Priority: 0/
Queue: SQL-Statement

Owner: Nobody in particular
Requestors: jason.v.robertson [...]

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

Subject: issue with parsing in SQL::Statement
Date: Wed, 16 Sep 2015 19:54:58 +0000
To: "bug-SQL-Statement [...]" <bug-SQL-Statement [...]>
From: "Robertson, Jason V" <jason.v.robertson [...]>
Download (untitled) / with headers
text/plain 1.3k
Hi, When I parse this SQL: my $sql = "SELECT * FROM sometable WHERE pkey='a' AND pk2='b' AND pk3='c' AND (step LIKE '%hello%' OR step LIKE '%xyz%') OR (step = 'asd' OR step2 = 'dasd')"; I get: SQL = SELECT * FROM registry_processcorner WHERE pkey='a' AND pk2='b' AND pk3='c' AND (step LIKE '%hello%' OR step LIKE '%xyz%') OR (step = 'asd' OR step2 = 'dasd') Use of uninitialized value in substitution iterator at /p/coeenv/proj_tools/hdkperlmod/jvrobert_sbox/lib/lib64/site_perl/SQL/ line 1691. Oddly, it works fine if I change my SQL to use lower-case 'and' and 'or'. Looking at the code a bit it looks like it's using " AND " as some sort of marker. I can sort of fix the problem by changing the group_ands function to use " AND " four spaces in front, not one) to mark completion, but this still seems a bit fragile. sub group_ands { my $str = shift; my $and_preds = shift || []; return ( $str, $and_preds ) unless $str =~ / AND / and $str =~ / OR /; return $str, $and_preds unless ( $str =~ /^(.*?) AND (.*)$/i ); my ( $front, $back ) = ( $1, $2 ); my $index = scalar @$and_preds; $front = $1 if ( $front =~ /^.* OR (.*)$/i ); $back = $1 if ( $back =~ /^(.*?) (OR|AND) .*$/i ); my $newpred = "$front AND $back"; push @$and_preds, $newpred; $str =~ s/\Q$newpred/~$index~/i; return group_ands( $str, $and_preds ); }
Download (untitled) / with headers
text/plain 188b
To break the silence: I can reproduce it - but I don't understand. I have several tests with upper case logical operators as well as lower cased ones. This needs truly deep investigation.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to