paulfitz / daff

align and compare tables
https://paulfitz.github.io/daff
MIT License
801 stars 67 forks source link

TableDiff.col_rename not updated when show_unchanged_columns = true #189

Open bmsq opened 1 year ago

bmsq commented 1 year ago

When constructing a TableDiff between the following tables with CompareFlags.show_unchanged_columns set to true:

Key,Name
Test1, AABBCC
Test2, DDEEFF
Key,Name2
Test1, AABBCC
Test2, DDEEFF

The TableDiff.col_renames property is set to 0 even though the resulting diff correctly shows the Name column being renamed to Name2.

I think this code is responsible for the issue:

if (!isEqual(v,pp,bb)) {
    have_schema = true;
    act = "(";
    act += v.toString(pp);
    act += ")";
    if (active_column!=null) {
        active_column[j] = 1;
        col_renames++;
    }
}

I don't understand why col_renames++ would only be performed when active_column!=null. Shouldn't this always be peformed?