Open KaiWW opened 3 years ago
Hi @KaiWW, I think the problem is that the initial call to compareTables
is being done without the flags
available to specify the primary key. Try calling it as compareTables(table1, table2, flags)
. For example in harness/BasicTest.hx
there is a test for primary keys that goes like this:
public function testNamedID(){
var table1 = Native.table(data1);
var table2 = Native.table(data2);
var flags = new coopy.CompareFlags();
flags.addPrimaryKey("Capital");
var alignment = coopy.Coopy.compareTables(table1,table2,flags).align();
var data_diff = [];
var table_diff = Native.table(data_diff);
var highlighter = new coopy.TableDiff(alignment,flags);
highlighter.hilite(table_diff);
assertEquals(""+table_diff.getCell(3,6),"Barcelona");
}
The "age" has been assigned as the primary key, but it's using "key" as the primary key.
before_data = [["key", "id", "name", "age"], ["1001", "1", "Cleo", "4"], ["1010", "2", "Pancakes", "2"]]
after_data = [["key", "id", "name", "age"], ["1001", "1", "Cleo", "5"], ["1009", "3", "Bailey", "1"], ["1012", "234", "John", "10"], ["1010", "32", "Dave", "21"]]
This gives me: [['@@', 'key', 'id', 'name', 'age'], ['->', '1001', '1', 'Cleo', '4->5'], ['+++', '1009', '3', 'Bailey', '1'], ['+++', '1012', '234', 'John', '10'], ['->', '1010', '2->32', 'Pancakes->Dave', '2->21']]