Add UTF-8 encoding support for query data and update version to 2.1.0#9
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds UTF-8 encoding support for SQL queries containing unicode characters (e.g., Chinese, Arabic, emoji, accented letters) to prevent server-side errors. The fix ensures queries are properly encoded before being sent to the Timbr API.
Key Changes:
- Modified
run_query()to explicitly encode string queries as UTF-8 bytes - Added comprehensive test coverage for unicode character handling
- Bumped version from 2.0.0 to 2.1.0
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pytimbr_api/timbr_http_connector.py | Added UTF-8 encoding logic with type checking for backward compatibility |
| test/test_encoding.py | New test file with 4 test cases covering unicode, multilingual text, and special characters |
| pyproject.toml | Version bump to 2.1.0 reflecting the new encoding functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
added 4 commits
December 10, 2025 12:50
… and update user naming convention in tests
… character preservation
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.
Add UTF-8 Encoding to Query Data
Summary
Fixed encoding issue when sending SQL queries with unicode characters to the Timbr API. Queries containing non-ASCII characters (e.g., Chinese, Arabic, emoji, accented letters) were not properly encoded, causing server-side errors.
Changes Made
1. Core Fix (
pytimbr_api/timbr_http_connector.py)run_query()function to explicitly encode string queries as UTF-8 bytesdata = query→data = query.encode('utf-8') if isinstance(query, str) else query2. Test Coverage (
test/test_encoding.py) - New filetest_run_query_with_unicode_characters- Tests Chinese, French accents, and emojitest_run_query_with_already_encoded_bytes- Ensures backward compatibility with byte inputstest_run_query_with_special_sql_characters- Tests SQL special characters and copyright symboltest_run_query_with_multilingual_text- Tests Latin, Cyrillic, Arabic, and Japanese characters3. Version Bump (
pyproject.toml)2.0.0to2.1.0(minor version bump for new functionality)4. Dependencies (
requirements.txt)Impact