Skip to content

Commit

Permalink
Merge #340 - Fix BufferedQuery when it has an odd number of backslash…
Browse files Browse the repository at this point in the history
…es in the end

Pull-request: #340

Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed Aug 14, 2021
2 parents 998338c + 97773b7 commit 9eac28f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Utils/BufferedQuery.php
Expand Up @@ -192,7 +192,7 @@ public function extract($end = false)
* be ignored.
*/
if ((($this->status & static::STATUS_COMMENT) === 0) && ($this->query[$i] === '\\')) {
$this->current .= $this->query[$i] . $this->query[++$i];
$this->current .= $this->query[$i] . ($i + 1 < $len ? $this->query[++$i] : '');
continue;
}

Expand Down
12 changes: 12 additions & 0 deletions tests/Utils/BufferedQueryTest.php
Expand Up @@ -113,6 +113,18 @@ public function extractProvider()
),
),

array(
"SELECT \\",
8,
array(
'parse_delimiter' => false,
'add_delimiter' => false,
),
array(
"SELECT \\",
),
),

array(
"CREATE TABLE `test` (\n" .
" `txt` varchar(10)\n" .
Expand Down

0 comments on commit 9eac28f

Please sign in to comment.