fix: correct Filter serialization for datetimes and booleans#1805
Open
jacalata wants to merge 3 commits into
Open
fix: correct Filter serialization for datetimes and booleans#1805jacalata wants to merge 3 commits into
jacalata wants to merge 3 commits into
Conversation
Fixes #1025 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tableau REST API requires boolean filter values to be lowercase
('true'/'false'), but Python's str(bool) produces 'True'/'False'.
Add explicit bool handling in Filter.__str__ alongside the existing
datetime fix, and expand test coverage to include bool, int, datetime
(format, timezone conversion, no-encoding), list edge cases, and the
invalid-operator-with-list guard.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Naive datetime objects passed to Filter now raise ValueError with a clear message instead of silently converting using the local system timezone, which would produce wrong UTC values on any non-UTC machine. Also adds a docstring to Filter.__str__ documenting the serialization rules for all supported value types. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
"2023-01-01 00:00:00"with space separator) instead of Tableau's required ISO-8601 UTC format ("2023-01-01T00:00:00Z"); this was causing server 400 errors for any datetime filtertrue/falseas required by the Tableau REST API; Python's defaultTrue/Falsecaused 400 errors on fields likeisCertifiedandhasExtractsValueErrorfor naive datetimes (no tzinfo) instead of silently producing a wrong-timezone value; naive datetimes were already broken before this fix (server 400), so this is not a regressionFilter.__str__documenting all value type serialization rulesCloses #1025
Schema compliance
Verified against ts-api_3_29.xsd:
xs:dateTimefields matchTABLEAU_DATE_FORMAT = "%Y-%m-%dT%H:%M:%SZ"exactlyxs:booleanfields (isCertified,hasExtracts, etc.) require lowercasetrue/falsesiteRole,jobType, etc.) serialize correctly via the existingstr()fallbackTest plan
python -m pytest test/test_filter.py -v-- 14 tests, all passcreatedAt:lt:2023-01-01T00:00:00Zin filter string (no%3A)ValueErrorisCertified:eq:trueandhasExtracts:eq:false(notTrue/False)🤖 Generated with Claude Code