Skip to content

feat: allow repeated --filter flags for exports - #443

Open
jacalata wants to merge 1 commit into
developmentfrom
jac/filter-repeatable
Open

feat: allow repeated --filter flags for exports#443
jacalata wants to merge 1 commit into
developmentfrom
jac/filter-repeatable

Conversation

@jacalata

Copy link
Copy Markdown
Contributor

Summary

--filter previously accepted a single value and required multi-pair filters to be joined with &, e.g. --filter "A=1&B=2". That parsing scheme prevents literal & inside a value (e.g. Product Name=AT&T 841000 Phone becomes Product Name=AT, then a bogus T 841000 Phone clause).

Make --filter repeatable via argparse action="append". Each flag now carries exactly one COLUMN=VALUE pair — no & splitting — so literal & in a value passes through untouched.

Back-compat

When only one --filter flag is present, the value is still split on & so existing scripts keep working:

--filter "Region=West&Product=Widget"     # still works
--filter "Region=West" --filter "Product=Widget"   # preferred
--filter "Product=AT&T"                    # new: repeated form allows '&' in value

Verification

End-to-end against a live workbook with product names containing &:

Filter Before After
--filter "Region=East" --filter "Product Name=AT&T 841000 Phone" parse error 1 row (AT&T 841000 Phone)
--filter "Region=East&Product Name=Widget" (back-compat) 1 row 1 row

Test plan

  • pytest tests/commands/test_datasources_and_workbooks_command.py tests/parsers/test_parser_export.py — 34 passed
  • Manual e2e: repeated --filter with & in the value returns the expected row
  • Manual e2e: single-flag &-joined form still parses and filters correctly

Follow-ups

Related work in flight:

🤖 Generated with Claude Code

Previously `--filter` accepted only one value, and multi-pair filtering
required joining pairs with '&' (e.g. `--filter "A=1&B=2"`). That
parsing scheme conflicts with values that legitimately contain '&'
(e.g. `Product Name=AT&T ...`).

Make `--filter` repeatable via argparse action="append". Each flag now
carries exactly one COLUMN=VALUE pair — no '&' splitting — so literal
'&' in a value passes through untouched.

Back-compat: when only one --filter flag is present, the value is still
split on '&' so existing scripts keep working. Users who need '&' in a
value should switch to the repeated-flag form.

Adds parser tests for the new syntax and unit tests for
apply_filters_from_args covering both forms.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jacalata
jacalata changed the base branch from main to development July 30, 2026 21:57
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