Skip to content

Commit b8334e3

Browse files
committed
Fix parsing error with C-style comments.
This is similar to the bug fixed in 5ec3bc9.
1 parent 69026f1 commit b8334e3

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/MySqlConnector/Core/SqlParser.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,10 @@ public void Parse(string sql)
218218
state = State.Hyphen;
219219
}
220220
else if (ch == '/' && index < sql.Length - 1 && sql[index + 1] == '*')
221+
{
222+
beforeCommentState = state;
221223
state = State.ForwardSlash;
224+
}
222225
else if (ch == '\'')
223226
state = State.SingleQuotedString;
224227
else if (ch == '"')

tests/MySqlConnector.Tests/StatementPreparerTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public class StatementPreparerTests
1616
[InlineData("SELECT Id\nFROM mytable\nWHERE column1 = 2 -- mycomment\nAND column2 = @param")]
1717
[InlineData("SELECT Id\nFROM mytable\nWHERE column1 = 2 -- mycomment\nAND column2 = @param")]
1818
[InlineData("SELECT Id\nFROM mytable\nWHERE column1 = 2 -- mycomment\n AND column2 = @param")]
19+
[InlineData("SELECT Id\nFROM mytable\nWHERE column1 = 2 /* mycomment */\n AND column2 = @param")]
20+
[InlineData("SELECT Id\nFROM mytable\nWHERE column1 = 2 /* mycomment */ AND column2 = @param")]
1921
public void Bug429(string sql)
2022
{
2123
var parameters = new MySqlParameterCollection();

0 commit comments

Comments
 (0)