Skip to content

Commit

Permalink
BaseDriver: fix parsing of SQL with consecutive delimiters [closes #112]
Browse files Browse the repository at this point in the history
  • Loading branch information
JanTvrdik committed Oct 4, 2020
1 parent bfc8b0a commit 6d5983d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Drivers/BaseDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function loadFile($path)
];

while (TRUE) {
if (preg_match($delimiterRe, $content, $match, 0, $queryOffset)) {
while (preg_match($delimiterRe, $content, $match, 0, $queryOffset)) {
$delimiter = $match[1];
$queryOffset += strlen($match[0]);
$parseOffset += strlen($match[0]);
Expand Down
24 changes: 24 additions & 0 deletions tests/cases/unit/BaseDriverTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,30 @@ class BaseDriverTest extends Tester\TestCase
"\n--\nSELECT 2",
],
],
[
implode("\n", [
'DELIMITER ;;',
'SELECT 1;;',
'DELIMITER ;',
'DELIMITER ;;',
'SELECT 2;;',
'DELIMITER ;',
]),
[
"\nSELECT 1",
"\nSELECT 2",
]
],
[
implode("\n", [
'SELECT 1;',
'DELIMITER ;;',
'DELIMITER ;',
]),
[
"SELECT 1",
]
],
];
}
}
Expand Down

0 comments on commit 6d5983d

Please sign in to comment.