fix: table diff is none when index or fk is modified (#280)

This commit is contained in:
vran
2023-12-01 19:46:40 +08:00
committed by GitHub
parent bb2e5a786a
commit 01fa3284b6
2 changed files with 16 additions and 0 deletions

View File

@@ -109,10 +109,21 @@ public class DocumentDiffChecker {
BaseTypeFieldEqualFunction eq = new BaseTypeFieldEqualFunction(IGNORE_FIELDS);
DiffType diffType = eq.apply(currentTable, originalTable) ? DiffType.NONE : DiffType.MODIFIED;
boolean indexModified = indexDiffs.stream()
.anyMatch(indexDiff -> indexDiff.getDiffType() != DiffType.NONE);
boolean triggerModified = triggerDiffs.stream()
.anyMatch(triggerDiff -> triggerDiff.getDiffType() != DiffType.NONE);
boolean fkModified = fkDiffs.stream()
.anyMatch(fkDiff -> fkDiff.getDiffType() != DiffType.NONE);
if (indexModified || triggerModified || fkModified) {
diffType = DiffType.MODIFIED;
}
// workaround for diffType = NONE
if (diffType == DiffType.NONE) {
originalTable = null;
}
return TableDocDiff.builder()
.id(currentTable.getId())
.diffType(diffType)