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.cursor.py: 84.8%
mssql_python.__init__.py: 84.9%🔗 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.
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.
0927dda to
fde7ea4
Compare
64a671a to
ce4f8c5
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 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ce4f8c5 to
0b66236
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 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0b66236 to
1ddc25f
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.
1ddc25f to
cf2ecbf
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.
cf2ecbf to
85b0ec6
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 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
85b0ec6 to
0629b3e
Compare
Add SQL_SS_UDT (-151) handling for SQL Server spatial types, enabling geography, geometry, and hierarchyid columns to be fetched as raw bytes. C++ changes (ddbc_bindings.cpp): - SQLGetData_wrap: SQL_SS_UDT falls through to SQL_BINARY - SQLBindColumns: SQL_SS_UDT falls through to SQL_BINARY - FetchBatchData: SQL_SS_UDT falls through to ProcessBinary - calculateRowSize: SQL_SS_UDT with LOB-size fallback for 0/SQL_NO_TOTAL - FetchMany_wrap/FetchAll_wrap: SQL_SS_UDT added to LOB detection Python changes: - constants.py: SQL_SS_UDT = -151 in ConstantsDDBC enum + get_valid_types() - cursor.py: SQL_SS_UDT -> SQL_C_BINARY in _get_c_type_for_sql_type, SQL_SS_UDT -> bytes in _map_data_type Tests: 37 tests covering all three spatial types across fetch paths (fetchone, fetchmany, fetchall, executemany), NULL handling, mixed-column queries, output converters, description metadata, spatial methods, error handling, and binary output consistency.
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.
0629b3e to
af13019
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 1 comment.
💡 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 = -151toConstantsDDBCenum andget_valid_types()cursor.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