Fixed "*DB.Raw()" bug where single or double quotes containing '@' were incorrectly identified as named variables#7207
Fixed "*DB.Raw()" bug where single or double quotes containing '@' were incorrectly identified as named variables#7207Rankgice wants to merge 6 commits into
Conversation
|
The failure of this test seems to be due to an issue with the test image container. I noticed that other PRs have also encountered the same problem as me. |
|
Hi, can you add some tests? |
Hello, of course not a problem. I will add some tests later |
I have added some test cases. May I proceed with the next review |
| builder.WriteByte(v) | ||
| continue | ||
| } | ||
| if v == '@' && !inName { |
There was a problem hiding this comment.
I think it would be better to add a check here to ensure that the previous character is not a " or '
There was a problem hiding this comment.
The logic of this code is
The second if:
When we first encounter '' or '', quotationMarks will be marked as' 'or' 'accordingly`
The first if:
When we have already been marked and encountered that mark (end mark) again, we will clear the mark
The third if:
When we have been marked and have not encountered the end mark, we will output it as it is
I didn't understand where you wanted to add a judgment
There was a problem hiding this comment.
I think it would be better to add a check here to ensure that the previous character is not a " or '
good!
What did this pull request do?
Fixed "*DB.Raw()" has a bug where single or double quotes containing '@' are incorrectly recognized as named variables.
When I call the Raw method, if the SQL contains a quote wrapped
@, then this@will not be treated as part of the string, but as a named parameter. I have increased the judgment of quotation marks to ensure that the content inside the quotation marks will not be recognized as distinctive symbols.User Case Description
Values
Origin
Result
After repair
Result