File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
tests/MySqlConnector.Tests Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -133,12 +133,12 @@ public void Parse(string sql)
133
133
if ( state != State . Beginning && state != State . Statement )
134
134
throw new InvalidOperationException ( "Unexpected state: {0}" . FormatInvariant ( state ) ) ;
135
135
136
- if ( ch == '-' )
136
+ if ( ch == '-' && index < sql . Length - 2 && sql [ index + 1 ] == '-' && sql [ index + 2 ] == ' ' )
137
137
{
138
138
beforeCommentState = state ;
139
139
state = State . Hyphen ;
140
140
}
141
- else if ( ch == '/' )
141
+ else if ( ch == '/' && index < sql . Length - 1 && sql [ index + 1 ] == '*' )
142
142
state = State . ForwardSlash ;
143
143
else if ( ch == '\' ' )
144
144
state = State . SingleQuotedString ;
Original file line number Diff line number Diff line change @@ -23,6 +23,27 @@ public void Bug429(string sql)
23
23
Assert . Equal ( sql . Replace ( "@param" , "123" ) , parsedSql ) ;
24
24
}
25
25
26
+ [ Theory ]
27
+ [ InlineData ( "UPDATE table SET a=a-@b;" ) ]
28
+ [ InlineData ( "UPDATE table SET a=a-/* subtract b */@b;" ) ]
29
+ [ InlineData ( "UPDATE table SET a=a+@b;" ) ]
30
+ [ InlineData ( "UPDATE table SET a=a/@b;" ) ]
31
+ [ InlineData ( "UPDATE table SET a=a-- \n -@b;" ) ]
32
+ [ InlineData ( "UPDATE table SET a = a-@b;" ) ]
33
+ [ InlineData ( "UPDATE table SET a = a+@b;" ) ]
34
+ [ InlineData ( "UPDATE table SET a = a - @b;" ) ]
35
+ [ InlineData ( "UPDATE table SET a=@b-a;" ) ]
36
+ [ InlineData ( "UPDATE table SET a=@b+a;" ) ]
37
+ [ InlineData ( "UPDATE table SET a = @b-a;" ) ]
38
+ [ InlineData ( "UPDATE table SET a = @b - a;" ) ]
39
+ public void Bug563 ( string sql )
40
+ {
41
+ var parameters = new MySqlParameterCollection ( ) ;
42
+ parameters . AddWithValue ( "@b" , 123 ) ;
43
+ var parsedSql = GetParsedSql ( sql , parameters ) ;
44
+ Assert . Equal ( sql . Replace ( "@b" , "123" ) , parsedSql ) ;
45
+ }
46
+
26
47
[ Theory ]
27
48
[ InlineData ( @"SELECT /* * / @param */ 1;" ) ]
28
49
[ InlineData ( "SELECT # @param \n 1;" ) ]
You can’t perform that action at this time.
0 commit comments