diff options
-rw-r--r-- | src/Utils/BufferedQuery.php | 6 | ||||
-rw-r--r-- | tests/Utils/BufferedQueryTest.php | 22 |
2 files changed, 25 insertions, 3 deletions
diff --git a/src/Utils/BufferedQuery.php b/src/Utils/BufferedQuery.php index 500862a..8aad59f 100644 --- a/src/Utils/BufferedQuery.php +++ b/src/Utils/BufferedQuery.php @@ -199,7 +199,7 @@ class BufferedQuery * treated differently, because of the preceding backslash, it will * be ignored. */ - if (($this->status & static::STATUS_COMMENT == 0) && ($this->query[$i] === '\\')) { + if ((($this->status & static::STATUS_COMMENT) == 0) && ($this->query[$i] === '\\')) { $this->current .= $this->query[$i] . $this->query[++$i]; continue; } @@ -209,14 +209,14 @@ class BufferedQuery */ if ($this->status === static::STATUS_STRING_SINGLE_QUOTES) { // Single-quoted strings like 'foo'. - if ($this->query[$i] === '\'' && $this->query[$i - 1] !== '\\') { + if ($this->query[$i] === '\'') { $this->status = 0; } $this->current .= $this->query[$i]; continue; } elseif ($this->status === static::STATUS_STRING_DOUBLE_QUOTES) { // Double-quoted strings like "bar". - if ($this->query[$i] === '"' && $this->query[$i - 1] !== '\\') { + if ($this->query[$i] === '"') { $this->status = 0; } $this->current .= $this->query[$i]; diff --git a/tests/Utils/BufferedQueryTest.php b/tests/Utils/BufferedQueryTest.php index ae406a4..41e14ff 100644 --- a/tests/Utils/BufferedQueryTest.php +++ b/tests/Utils/BufferedQueryTest.php @@ -114,6 +114,28 @@ class BufferedQueryTest extends TestCase ), array( + "CREATE TABLE `test` (\n" . + " `txt` varchar(10)\n" . + ");\n" . + "INSERT INTO `test` (`txt`) VALUES('abc');\n" . + "INSERT INTO `test` (`txt`) VALUES('\\\\');\n" . + "INSERT INTO `test` (`txt`) VALUES('xyz');\n", + 8, + array( + 'parse_delimiter' => true, + 'add_delimiter' => true, + ), + array( + "CREATE TABLE `test` (\n" . + " `txt` varchar(10)\n" . + ");", + "INSERT INTO `test` (`txt`) VALUES('abc');", + "INSERT INTO `test` (`txt`) VALUES('\\\\');", + "INSERT INTO `test` (`txt`) VALUES('xyz');", + ) + ), + + array( 'SELECT """""""";' . 'SELECT """\\\\"""', 8, |