daff icon indicating copy to clipboard operation
daff copied to clipboard

[NodeJS] `--fail-if-diff` flag does not work well with `--ignore` column when comparing SQLite files

Open kidlab opened this issue 8 months ago • 0 comments

Context: I'm using the NodeJS version 1.4.2 of daff:

npm install daff -g
npx daff version
# 1.4.2

Given these two SQLite files:

sqlite3 data1.sqlite <<SQL
CREATE TABLE data(id TEXT PRIMARY KEY, value TEXT, timestamp TEXT);
INSERT INTO data VALUES('1', 'foo', '2025-05-01');
INSERT INTO data VALUES('2', 'bar', '2025-05-02');
SQL
sqlite3 data2.sqlite <<SQL
CREATE TABLE data(id TEXT PRIMARY KEY, value TEXT, timestamp TEXT);
INSERT INTO data VALUES('1', 'foo', '2025-05-03');
INSERT INTO data VALUES('2', 'bar', '2025-05-01');
SQL

I'm comparing two files with --fail-if-diff and want to use the status code to know if the files are different or not (0 if equal, 1 if different, 2 if problem). Also the timestamp column is not relevant in this comparison, so I'll ignore it. Here's the command:

npx daff diff data1.sqlite data2.sqlite \
    --input-format sqlite3 \
    --fail-if-diff \
    --unordered \
    --index \
    --id id \
    --ignore timestamp \
    --output-format html \
    --output diff.html

Then, the output diff.html looks like this: Image

And the returned status code is 1:

echo $?
1

Please correct me if the following expected results are wrong:

  1. There should be no diff for base.
  2. The status code should be 0 in this case.

kidlab avatar Jun 13 '25 05:06 kidlab