sulheru / 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

Newline characters dropped #37

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

<?php

require("php-sql-parser.php");
require("php-sql-creator.php");

error_reporting( E_ALL );
ini_set( 'display_errors', 1 );

$sql = "INSERT INTO test (`name`, `test`) VALUES ('Hello this is what happens\n 
when new lines are involved', '')";

$parser = new PHPSQLParser($sql);
$ben = new PHPSQLCreator($parser->parsed);

echo "<textarea>";
echo $sql;
echo "</textarea>";

echo "<textarea>";
print_r( $parser->parsed );
echo "</textarea>";

echo "<textarea>";
echo $ben->created;
echo "</textarea>"; 

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

Expected output
---------------
INSERT INTO test (`name`, `test`) VALUES ('Hello this is what happens
 when new lines are involved', '')

Observed output
---------------
INSERT INTO test (`name`,`test`) VALUES ('Hello this is what happens  when new 
lines are involved','')

What version of the product are you using? On what operating system?
https://www.phosco.info/publicsvn/php-sql-parser/trunk/ REV 136

Please provide any additional information below.
It appears that it's dropped in the parser class rather than the creator class.

Original issue reported on code.google.com by ben.swin...@gmail.com on 12 Mar 2012 at 11:29

GoogleCodeExporter commented 9 years ago
Hm, this sems to be a bigger problem. Linefeeds are token delimiter, so I 
replace it within replaceSpecialCharacters(). There is no effect on the 
statement, except the special characters within string literals. So there is 
already a TODO within the code :-) I will see, what I can do.

Original comment by pho...@gmx.de on 12 Mar 2012 at 2:48

GoogleCodeExporter commented 9 years ago

Original comment by pho...@gmx.de on 13 Mar 2012 at 12:22

GoogleCodeExporter commented 9 years ago
See the progress on branches/whitespace.

Original comment by pho...@gmx.de on 21 Mar 2012 at 10:24

GoogleCodeExporter commented 9 years ago
I have finished the changes for this issue, all tests are green. Can you check 
out the version on 
http://php-sql-parser.googlecode.com/svn/branches/whitespace? Maybe you have 
additional test cases. It is possible, that the creator can not handle the new 
output structure for UPDATE statements.

Original comment by pho...@gmx.de on 22 Mar 2012 at 9:56

GoogleCodeExporter commented 9 years ago
I have merged the branch into the trunk tree. The creator tests are also green.

Original comment by pho...@gmx.de on 22 Mar 2012 at 1:12

GoogleCodeExporter commented 9 years ago
Solution available on http://php-sql-parser.googlecode.com/svn/tags/2012-03-23.
Test case seems to be ok.

Original comment by pho...@gmx.de on 23 Mar 2012 at 9:44