Skip to content

Preserve falsy values (0, False) in jira and latex exports#643

Open
koriyoshi2041 wants to merge 1 commit into
jazzband:masterfrom
koriyoshi2041:fix/preserve-falsy-values-jira-latex
Open

Preserve falsy values (0, False) in jira and latex exports#643
koriyoshi2041 wants to merge 1 commit into
jazzband:masterfrom
koriyoshi2041:fix/preserve-falsy-values-jira-latex

Conversation

@koriyoshi2041

Copy link
Copy Markdown

The JIRA and LaTeX serializers decide whether a cell is empty with a plain truthiness test:

# _jira.py
delimiter.join([str(item) if item else " " for item in row])
# _latex.py
new_row = [cls._escape_tex_reserved_symbols(str(item)) if item else "" for item in row]

So 0, 0.0, and False — all valid data — are treated as missing and exported as blank cells, silently losing data. For example tablib.Dataset([0, False, "c"]).jira produced | | |c| instead of |0|False|c|.

The HTML format already does this correctly with str(item) if item is not None else "", so "blank only for missing values" is the intended contract. This changes both serializers to test item not in (None, ""), which keeps the existing None/empty-string behaviour (still rendered blank) while preserving real falsy values.

Added test_jira_export_falsy_values and test_latex_export_falsy_values; the existing *_none_* tests still pass. pytest -k "jira or latex" is green (12 passed).

The jira and latex serializers used a truthiness test (`if item`) to decide
whether a cell is empty, so 0, 0.0, and False were exported as blank cells and
silently lost. Only None and empty strings should render as blank, which is
what the html format already does (`if item is not None`). Check
`item not in (None, '')` instead so real falsy values are kept.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant