FEAT: Add spatial type support (geography, geometry, hierarchyid)#423
FEAT: Add spatial type support (geography, geometry, hierarchyid)#423dlevy-msft-sql wants to merge 1 commit intomicrosoft:mainfrom
Conversation
8bcb847 to
ce07df5
Compare
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changes
Summary
📋 Files Needing Attention📉 Files with overall lowest coverage (click to expand)mssql_python.pybind.logger_bridge.hpp: 58.8%
mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.row.py: 66.2%
mssql_python.pybind.ddbc_bindings.cpp: 69.4%
mssql_python.pybind.ddbc_bindings.h: 69.7%
mssql_python.pybind.connection.connection.cpp: 75.3%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection_pool.cpp: 79.6%
mssql_python.connection.py: 84.1%
mssql_python.cursor.py: 84.8%🔗 Quick Links
|
There was a problem hiding this comment.
Pull request overview
Adds handling for SQL Server CLR user-defined spatial types (reported via ODBC as SQL_SS_UDT / -151) so geography, geometry, and hierarchyid can be fetched as bytes instead of raising “unsupported type” errors.
Changes:
- Add
SQL_SS_UDTsupport in the native ODBC fetch/bind paths by treating it like binary data (including LOB/streaming detection). - Extend Python type mappings so
SQL_SS_UDTmaps toSQL_C_BINARYandbytes(includingcursor.descriptiontype codes). - Add a comprehensive spatial-types test suite covering fetch methods, NULLs, metadata, converters, and error cases.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
mssql_python/pybind/ddbc_bindings.cpp |
Handles SQL_SS_UDT in SQLGetData, batch binding, row-size calculation, and LOB detection to fetch spatial UDTs as binary. |
mssql_python/constants.py |
Introduces SQL_SS_UDT = -151 in ConstantsDDBC. |
mssql_python/cursor.py |
Maps SQL_SS_UDT to SQL_C_BINARY for binding and to bytes for cursor.description type mapping. |
tests/test_017_spatial_types.py |
Adds test coverage for geography/geometry/hierarchyid fetch behaviors and related metadata/converter scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ce07df5 to
7c474e8
Compare
|
Thanks for the review — both comments were valid and have been fixed in the amended commit: Comment 1 — Unused Comment 2 — |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1d85de4 to
8088d9c
Compare
Add SQL_SS_UDT (-151) handling so geography, geometry, and hierarchyid columns are fetched as bytes instead of raising errors. C++ changes (ddbc_bindings.cpp): - Define SQL_SS_UDT constant - Add case fallthroughs to SQL_BINARY in SQLGetData_wrap, SQLBindColums, and FetchBatchData - Separate calculateRowSize case with LOB-size fallback - Include SQL_SS_UDT in LOB detection for FetchMany_wrap and FetchAll_wrap Python changes: - constants.py: SQL_SS_UDT = -151 in ConstantsDDBC enum - cursor.py: SQL_SS_UDT -> SQL_C_BINARY in sql_to_c_type map - cursor.py: SQL_SS_UDT -> bytes in sql_to_python_type map Tests: - 37 tests covering all three UDT types (geography, geometry, hierarchyid) - Fetch paths: fetchone, fetchmany, fetchall, executemany - NULL handling, mixed columns, binary round-trips, error cases - Output converter and cursor.description metadata verification
8088d9c to
0927dda
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Work Item / Issue Reference
Summary
Adds
SQL_SS_UDT(-151) handling sogeography,geometry, andhierarchyidcolumns are fetched asbytesinstead of raising errors. These SQL Server CLR User-Defined Types all report asSQL_SS_UDTvia ODBC and were previously unhandled in both the C++ binding layer and Python type maps.Changes
ddbc_bindings.cppSQL_SS_UDTconstant; addcase SQL_SS_UDT:fallthroughs toSQL_BINARYinSQLGetData_wrap,SQLBindColums, andFetchBatchData; separatecalculateRowSizecase with LOB-size fallback; include in LOB detection forFetchMany_wrapandFetchAll_wrapconstants.pySQL_SS_UDT = -151toConstantsDDBCenumcursor.pySQL_SS_UDT -> SQL_C_BINARYinsql_to_c_typemap; addSQL_SS_UDT -> bytesinsql_to_python_typemaptest_017_spatial_types.pyTesting
ddbc_bindings.cp313-arm64.pydwith 0 errorstest_no_segfault_on_gcWinError 50), 8 skipped