-
Notifications
You must be signed in to change notification settings - Fork 27
FEAT: Complex data type support- uniqueidentifier #236
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 PR adds comprehensive support for Python's uuid.UUID type when working with SQL Server UNIQUEIDENTIFIER columns. It enables native UUID handling for both parameter binding and result retrieval.
- Added parameter mapping for UUID objects to SQL_GUID type in cursor.py
- Implemented UUID byte conversion and marshaling in the C++ binding layer
- Enhanced result fetching to return Python UUID objects instead of raw bytes
- Added comprehensive test coverage for UUID operations including NULL handling
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| mssql_python/cursor.py | Maps UUID parameters to SQL_GUID type and converts UUID objects to bytes |
| mssql_python/pybind/ddbc_bindings.cpp | Implements UUID parameter binding and result conversion with proper byte order handling |
| tests/test_004_cursor.py | Adds test cases for UUID insertion, retrieval, and NULL value handling |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
75f7a57 to
e9aa833
Compare
1b059c3 to
c03b72b
Compare
51842bf to
b7fceaa
Compare
sumitmsft
left a comment
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.
Left a few comments
7b10bf4 to
32e7d04
Compare
Work Item / Issue Reference
Summary
This pull request adds comprehensive support for Python's
uuid.UUIDtype when interacting with SQL ServerUNIQUEIDENTIFIERcolumns. It updates both the parameter binding and result retrieval logic to handle UUIDs as native Python objects, ensuring correct type mapping, byte order, and conversion in both directions. Additionally, new tests are introduced to verify correct insertion and retrieval of UUID values, including edge cases withNone.UUID/UNIQUEIDENTIFIER Support Improvements:
mssql_python/cursor.pyto map Pythonuuid.UUIDobjects to the correct SQL types and convert them to raw bytes before sending to SQL Server. [1] [2]mssql_python/pybind/ddbc_bindings.cpp) to correctly marshal UUIDs between Python and SQL Server, including proper byte order conversion and error handling for incorrect UUID sizes.UNIQUEIDENTIFIERcolumns back into Pythonuuid.UUIDobjects, both for single-row and batch fetches, and to handleNULLvalues gracefully. [1] [2]Testing Enhancements:
tests/test_004_cursor.pyto verify correct insertion, retrieval, and handling ofNonevalues in UUID columns, as well as round-trip integrity for multiple UUIDs. [1] [2]