Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Statements/CreateStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,10 @@ public function parse(Parser $parser, TokensList $list)

for (; $list->idx < $list->count; ++$list->idx) {
$token = $list->tokens[$list->idx];
if ($token->type === Token::TYPE_DELIMITER) {
break;
}

$this->body[] = $token;
}
} elseif ($this->options->has('VIEW')) {
Expand Down Expand Up @@ -781,6 +785,10 @@ public function parse(Parser $parser, TokensList $list)

for (; $list->idx < $list->count; ++$list->idx) {
$token = $list->tokens[$list->idx];
if ($token->type === Token::TYPE_DELIMITER) {
break;
}

$this->body[] = $token;
}
} else {
Expand Down
4 changes: 3 additions & 1 deletion tests/Builder/CreateStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,8 @@ public function testBuilderCreateProcedure(): void
public function testBuilderCreateFunction(): void
{
$parser = new Parser(
'CREATE DEFINER=`root`@`localhost`'
'DELIMITER $$' . "\n"
. 'CREATE DEFINER=`root`@`localhost`'
. ' FUNCTION `inventory_in_stock`(`p_inventory_id` INT) RETURNS tinyint(1)'
. ' READS SQL DATA'
. ' COMMENT \'My best function written by a friend\'\'s friend\''
Expand Down Expand Up @@ -663,6 +664,7 @@ public function testBuilderTrigger(): void
public function testBuilderRoutine(): void
{
$parser = new Parser(
'DELIMITER $$' . "\n" .
'CREATE FUNCTION test (IN `i` INT) RETURNS VARCHAR ' .
'BEGIN ' .
'DECLARE name VARCHAR DEFAULT ""; ' .
Expand Down
3 changes: 3 additions & 0 deletions tests/Parser/ParserLongExportsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public function testParsephpMyAdminDump(): void
'SET @OLD_CHARACTER_SET_RESULTS = @@CHARACTER_SET_RESULTS',
'SET @OLD_COLLATION_CONNECTION = @@COLLATION_CONNECTION',
'SET NAMES utf8mb4',
'SET CHARACTER_SET_CLIENT = @OLD_CHARACTER_SET_CLIENT',
'SET CHARACTER_SET_RESULTS = @OLD_CHARACTER_SET_RESULTS',
'SET COLLATION_CONNECTION = @OLD_COLLATION_CONNECTION',
], $collectedSetStatements);

foreach ($parser->statements as $stmt) {
Expand Down
1 change: 1 addition & 0 deletions tests/data/parser/parseCreateFunction.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
DELIMITER $$
CREATE FUNCTION F_TEST(uid INT) RETURNS VARCHAR
BEGIN
DECLARE username VARCHAR DEFAULT "";
Expand Down
Loading