-
Notifications
You must be signed in to change notification settings - Fork 286
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
bugfix: error image when use null value as image query condition in insert on duplicate #704 #725
base: master
Are you sure you want to change the base?
Conversation
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
if len(paramMap) == 0 || len(metaData.Indexs) == 0 { | ||
return "", nil, nil | ||
} | ||
hasPK := false |
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.
use goto
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.
use
goto
goto 不太好理解?
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.
use
goto
goto 不太好理解?
那这里还需要改为goto吗
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.
不要使用 goto 吧
|
||
// Reset primary keys map | ||
u.BeforeImageSqlPrimaryKeys = make(map[string]bool) | ||
|
||
pkIndexMap := u.getPkIndex(insertStmt, metaData) | ||
var pkIndexArray []int |
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.
use make and cap
for i := 0; i < len(insertRows); i++ { | ||
var rowConditions []string | ||
var rowArgs []driver.Value | ||
usedParams := make(map[string]bool) |
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.
add cap
把单测也加上 |
// Test case for null unique index | ||
{ | ||
execCtx: &types.ExecContext{ | ||
Query: "insert into t_unique(id, a, b) values(1, NULL, 2) on duplicate key update b = 5", |
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.
values(1, NULL, 2) 换成占位符 ?
{ | ||
execCtx: &types.ExecContext{ | ||
Query: "insert into t_unique(id, a, b) values(1, NULL, 2) on duplicate key update b = 5", | ||
MetaDataMap: map[string]types.TableMeta{"t_unique": tableMeta1}, |
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.
MetaDataMap 会在后面使用,确保这个 key 被用到,可以 debug 看看是否走到了你预想的步骤
{ | ||
execCtx: &types.ExecContext{ | ||
Query: "insert into t_unique(id, b) values(NULL, 2) on duplicate key update b = 5", | ||
MetaDataMap: map[string]types.TableMeta{"t_unique": tableMeta1}, |
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.
t_unique 改为 t_user
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
Quality Gate passedIssues Measures |
What this PR does:
This PR addresses the SQL generation and parameter handling issues in the MySQL Insert On Duplicate Key Update undo log builder. It improves the handling of primary key conditions, parameter type safety, and fixes spacing issues in SQL generation.
Which issue(s) this PR fixes:
Fixes #704
Special notes for your reviewer:
Through these improvements, I aim to provide a more robust and efficient solution to meet the project's development needs. If you encounter any issues with the refactoring, please feel free to contact me.
Does this PR introduce a user-facing change?: