paulfitz / daff

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

Empty string gets converted to NULL #96

Closed spivachek closed 6 years ago

spivachek commented 7 years ago

Hi, Paul! Want to thank you for the great tool (which I forgot to do in my previous issue). This time it's about NULLs. Examples:

daff prints empty string from the second table as NULL:

$ daff diff --no-color <(echo -e "id,name\n1, ") <(echo -e "id,name\n1,")
@@,id,name
->,1," ->NULL"

But if that's not an update (id changed to 2), empty string is left untouched:

$ daff diff --no-color <(echo -e "id,name\n1, ") <(echo -e "id,name\n2,")
@@,id,name
+++,2,
---,1," "

I've read about NULL encoding in http://specs.okfnlabs.org/tabular-diff-format/. If I understood it right, there should be no confusion between empty string and null value: NULL is null value, _NULL is "NULL" string, __NULL is "_NULL" string, etc., and empty string is just empty string. So is there a need to convert empty string to NULL? And what if I have a nullable string column? I was supposed to receive empty string, but got NULL.

Thanks

paulfitz commented 6 years ago

Hmm this isn't great. id,name\n1, has a cell with an empty string, rather than null, so there's definitely an issue here. Will (belatedly) investigate.

paulfitz commented 6 years ago

Should be fixed as of 1.3.36.