-
Notifications
You must be signed in to change notification settings - Fork 188
syncer: fix generated column in where condition #60
Conversation
PTAL @GregoryIan @csuzhangxc |
/run-all-tests |
3 similar comments
/run-all-tests |
/run-all-tests |
/run-all-tests |
syncer/dml.go
Outdated
|
||
if len(defaultIndexColumns) == 0 { | ||
defaultIndexColumns = getAvailableIndexColumn(indexColumns, oldValues) | ||
defaultIndexColumns = getAvailableIndexColumn(originalIndexColumns, oriOldValues) | ||
} | ||
|
||
ks := genMultipleKeys(columns, oldValues, indexColumns) |
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.
should we use oriOldValues
?
Rest LGTM |
PTAL @GregoryIan |
sqls := make([]string, 0, len(dataSeq)) | ||
keys := make([][]string, 0, len(dataSeq)) | ||
values := make([][]interface{}, 0, len(dataSeq)) | ||
columnList := genColumnList(columns) | ||
columnPlaceholders := genColumnPlaceholders(len(columns)) | ||
for _, data := range dataSeq { | ||
for dataIdx, data := range dataSeq { | ||
if len(data) != len(columns) { |
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.
also check originalColumns
and originalDataSeq
?
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.
not needed, data/columns and origianlData/originalColumns have the same length distance ?
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 column and data length check in generated column prune
syncer/dml.go
Outdated
@@ -140,16 +177,30 @@ func genUpdateSQLs(schema string, table string, data [][]interface{}, columns [] | |||
changedValues = append(changedValues, castUnsigned(changedData[i], columns[i].unsigned, columns[i].tp)) | |||
} | |||
|
|||
oriOldValues := make([]interface{}, 0, len(oriOldData)) |
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.
genUpdateSQLs
, `genInsertSQLs`` has these codes in same pattern:
...values
for i := range data {
values = append(values,....)
}
if len(columns) == len(originalColumns) {
originalVals = values
} else {
for {....}
}
can we extract it a function?
LGTM |
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 problem does this PR solve?
Currently we remove all generated column for DML, but generated column in where condition is valid.
What is changed and how it works?
update
/delete
DMLCheck List
Tests
Side effects