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)
133133 if ( state != State . Beginning && state != State . Statement )
134134 throw new InvalidOperationException ( "Unexpected state: {0}" . FormatInvariant ( state ) ) ;
135135
136- if ( ch == '-' )
136+ if ( ch == '-' && index < sql . Length - 2 && sql [ index + 1 ] == '-' && sql [ index + 2 ] == ' ' )
137137 {
138138 beforeCommentState = state ;
139139 state = State . Hyphen ;
140140 }
141- else if ( ch == '/' )
141+ else if ( ch == '/' && index < sql . Length - 1 && sql [ index + 1 ] == '*' )
142142 state = State . ForwardSlash ;
143143 else if ( ch == '\' ' )
144144 state = State . SingleQuotedString ;
Original file line number Diff line number Diff line change @@ -23,6 +23,27 @@ public void Bug429(string sql)
2323 Assert . Equal ( sql . Replace ( "@param" , "123" ) , parsedSql ) ;
2424 }
2525
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+
2647 [ Theory ]
2748 [ InlineData ( @"SELECT /* * / @param */ 1;" ) ]
2849 [ InlineData ( "SELECT # @param \n 1;" ) ]
You can’t perform that action at this time.
0 commit comments