Skip to content

Commit

Permalink
0002874: [SQL Server] When capture changes only is enabled, pk is not
Browse files Browse the repository at this point in the history
compared and potential syntax error
  • Loading branch information
erilong committed Oct 21, 2016
1 parent e810c88 commit c4c7dd0
Showing 1 changed file with 13 additions and 13 deletions.
Expand Up @@ -212,21 +212,21 @@ private String buildNonLobColumnsAreNotEqualString(Table table, String table1Nam
StringBuilder builder = new StringBuilder();

for(Column column : table.getColumns()){
boolean isLob = isNotComparable(column);
if (isNotComparable(column)) {
continue;
}
if (builder.length() > 0) {
builder.append(" or ");
}

if(isLob || column.isPrimaryKey()){
continue;
}
if(builder.length() > 0){
builder.append(" or ");
}

builder.append(String.format("((%1$s.\"%2$s\" IS NOT NULL AND %3$s.\"%2$s\" IS NOT NULL AND %1$s.\"%2$s\"<>%3$s.\"%2$s\") or (%1$s.\"%2$s\" IS NULL AND %3$s.\"%2$s\" IS NOT NULL) or (%1$s.\"%2$s\" IS NOT NULL AND %3$s.\"%2$s\" IS NULL))",
table1Name, column.getName(), table2Name));

builder.append(String.format("((%1$s.\"%2$s\" IS NOT NULL AND %3$s.\"%2$s\" IS NOT NULL AND %1$s.\"%2$s\"<>%3$s.\"%2$s\") or "
+ "(%1$s.\"%2$s\" IS NULL AND %3$s.\"%2$s\" IS NOT NULL) or "
+ "(%1$s.\"%2$s\" IS NOT NULL AND %3$s.\"%2$s\" IS NULL))", table1Name, column.getName(), table2Name));
}

return "(" + builder.toString() + ")";
if (builder.length() == 0) {
builder.append("1=1");
}
return builder.toString();
}

private String buildNonLobColumnsString(Table table){
Expand Down

0 comments on commit c4c7dd0

Please sign in to comment.