Skip to content

Conversation

gargsaumya
Copy link
Contributor

@gargsaumya gargsaumya commented Aug 5, 2025

Work Item / Issue Reference

AB#37664

GitHub Issue: #<ISSUE_NUMBER>


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:

  • Updated the _map_sql_type method in cursor.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:

  • Added a new test test_emoji_round_trip in test_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.

@Copilot Copilot AI review requested due to automatic review settings August 5, 2025 07:05
Copy link
Contributor

@Copilot Copilot AI left a 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

@github-actions github-actions bot added the pr-size: small Minimal code update label Aug 6, 2025
@gargsaumya gargsaumya force-pushed the saumya/emoji-support branch from 353dad1 to 6ef29c1 Compare August 6, 2025 10:18
@github-actions github-actions bot added pr-size: small Minimal code update and removed pr-size: small Minimal code update labels Aug 6, 2025
bewithgaurav
bewithgaurav previously approved these changes Aug 6, 2025
@github-actions github-actions bot added pr-size: small Minimal code update and removed pr-size: small Minimal code update labels Aug 6, 2025
bewithgaurav
bewithgaurav previously approved these changes Aug 6, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Aug 28, 2025
@gargsaumya gargsaumya force-pushed the saumya/emoji-support branch from 8c34858 to 056c810 Compare August 28, 2025 13:35
@github-actions github-actions bot added pr-size: large Substantial code update and removed pr-size: medium Moderate update size labels Aug 28, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: large Substantial code update labels Aug 28, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Aug 28, 2025
@gargsaumya gargsaumya merged commit 8968a5c into main Aug 28, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-size: medium Moderate update size
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants