Ignore trailing comments when splitting SQL batches
A comment after the last semicolon ("SELECT 1; -- note") became a
statement of its own. It is not a read, so the whole batch asked for
confirmation and the comment was then sent to the database. Drop parts
that contain only comments.
This commit is contained in:
@@ -87,8 +87,9 @@ class SqlGuard
|
||||
|
||||
$statements[] = trim($current);
|
||||
|
||||
// A trailing comment ("SELECT 1; -- note") is not a statement
|
||||
return array_values(array_filter($statements, function ($s) {
|
||||
return $s !== '';
|
||||
return trim(self::removeComments($s)) !== '';
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user