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:
@@ -167,6 +167,10 @@ class SqlGuardTest extends TestCase
|
||||
["/* it's; here */ SELECT 1; SELECT 2", ["/* it's; here */ SELECT 1", 'SELECT 2']],
|
||||
['SELECT \$1; SELECT 2', ['SELECT \$1', 'SELECT 2']],
|
||||
[' ; ;SELECT 1;', ['SELECT 1']],
|
||||
["SELECT 1; --full", ['SELECT 1']],
|
||||
["SELECT 1; -- note\nSELECT 2", ['SELECT 1', "-- note\nSELECT 2"]],
|
||||
["-- only a comment", []],
|
||||
["SELECT 1; /* note */", ['SELECT 1']],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user