-
Notifications
You must be signed in to change notification settings - Fork 20
FEAT: Support Emojis for data types #166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request enhances Unicode string handling in the SQL type mapping logic to properly support emojis and special characters. The key improvement addresses the incorrect sizing calculation for Unicode strings by using UTF-16 code unit length instead of Python string length.
- Updated
_map_sql_type
method to calculate UTF-16 code unit length for Unicode parameters - Added comprehensive test coverage for emoji and special character round-trip operations
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
mssql_python/cursor.py | Fixed Unicode string length calculation by using UTF-16 encoding length instead of Python string length |
tests/test_004_cursor.py | Added comprehensive test for emoji and special character round-trip database operations |
353dad1
to
6ef29c1
Compare
8c34858
to
056c810
Compare
Work Item / Issue Reference
Summary
This pull request improves Unicode string handling in the SQL type mapping logic and adds comprehensive tests for round-tripping emoji and special characters in the database. The main focus is on ensuring that Unicode strings, including those with emojis and special characters, are correctly mapped and stored in SQL Server.
Unicode string mapping improvements:
_map_sql_type
method incursor.py
to use the UTF-16 code unit length for Unicode string parameters instead of the Python string length, ensuring correct sizing for both long and short Unicode strings. [1] [2]Testing enhancements:
test_emoji_round_trip
intest_004_cursor.py
to verify that various emoji, accented, and non-Latin characters can be inserted and retrieved accurately from the database, improving coverage for Unicode edge cases.