rickywu-posh / php-sql-parser

Automatically exported from code.google.com/p/php-sql-parser
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Working with escaped values #40

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. The following two queries won't be exploded consistently:

$q1 = "select a from t where x = \"a'b\\cd\" and y = 'ef\"gh'";
$q2 = "select a from t where x = \"abcd\" and y = 'efgh'";

$parser = new CPHPSQLParser();
print_r($parser->parse($q1));
print_r($parser->parse($q2));

What is the expected output? What do you see instead?

$q1 and $q2 should have in the [WHERE] part two colref/operator/const parts, 
with only different constant/colref values. Instead, the [WHERE] for q1 has 
only one colref/operator/const part, like this: colref = "x", operator = "=" , 
const "a'b\cd" and y = 'ef"gh'

What version of the product are you using? On what operating system?

tags/2012-03-23 / win7

Please provide any additional information below.

The parser doesn't correctly handle values with escaped chars inside (no matter 
if the value is single or double quoted inside the query).

Original issue reported on code.google.com by lucian.t...@gmail.com on 30 Mar 2012 at 1:55

GoogleCodeExporter commented 8 years ago
WTF! :-)

I have changed the handling of backticks and quotes again. Try the current 
version on /trunk. There is a test case with your example, and it seems to 
work, but double check it with some other queries.

Original comment by pho...@gmx.de on 2 Apr 2012 at 7:27

GoogleCodeExporter commented 8 years ago
Thanks for the quick reply and the quick fix also :) it works now

Original comment by lucian.t...@gmail.com on 2 Apr 2012 at 8:22

GoogleCodeExporter commented 8 years ago

Original comment by pho...@gmx.de on 2 Apr 2012 at 8:56