-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed "*DB.Raw()" bug where single or double quotes containing '@' were incorrectly identified as named variables #7207
base: master
Are you sure you want to change the base?
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 |
} else if quotationMarks == '"' || quotationMarks == '\'' { | ||
builder.WriteByte(v) | ||
continue | ||
} | ||
if v == '@' && !inName { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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