Commit 7ebef4f
FEAT: Add spatial type support (geography, geometry, hierarchyid) (#423)
### Work Item / Issue Reference
> GitHub Issue #352
-------------------------------------------------------------------
### Summary
Adds `SQL_SS_UDT` (-151) handling so `geography`, `geometry`, and
`hierarchyid` columns are fetched as `bytes` instead of raising errors.
These SQL Server CLR User-Defined Types all report as `SQL_SS_UDT` via
ODBC and were previously unhandled in both the C++ binding layer and
Python type maps.
## Changes
| File | Change |
|------|--------|
| `ddbc_bindings.cpp` | Define `SQL_SS_UDT` constant; add `case
SQL_SS_UDT:` fallthroughs to `SQL_BINARY` in `SQLGetData_wrap`,
`SQLBindColums`, and `FetchBatchData`; separate `calculateRowSize` case
with LOB-size fallback; include in LOB detection for `FetchMany_wrap`
and `FetchAll_wrap` |
| `constants.py` | Add `SQL_SS_UDT = -151` to `ConstantsDDBC` enum and
`get_valid_types()` |
| `cursor.py` | Add `SQL_SS_UDT -> SQL_C_BINARY` in `sql_to_c_type` map;
add `SQL_SS_UDT -> bytes` in `sql_to_python_type` map |
| `test_017_spatial_types.py` | 37 tests covering geography, geometry,
and hierarchyid: fetch paths (fetchone/fetchmany/fetchall/executemany),
NULL handling, mixed columns, binary round-trips, output converters,
cursor.description metadata, error cases |
## Testing
- Built `ddbc_bindings.cp313-arm64.pyd` with 0 errors
- Existing test suite: 639 passed, 1 pre-existing failure (unrelated
`test_no_segfault_on_gc` WinError 50), 8 skipped
- Spatial tests require live SQL Server connection with
geography/geometry/hierarchyid support
Co-authored-by: gargsaumya <saumyagarg.100@gmail.com>1 parent 6a5491c commit 7ebef4f
File tree
4 files changed
+844
-3
lines changed- mssql_python
- pybind
- tests
4 files changed
+844
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
| |||
374 | 375 | | |
375 | 376 | | |
376 | 377 | | |
| 378 | + | |
377 | 379 | | |
378 | 380 | | |
379 | 381 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
865 | 865 | | |
866 | 866 | | |
867 | 867 | | |
| 868 | + | |
868 | 869 | | |
869 | 870 | | |
870 | 871 | | |
| |||
1052 | 1053 | | |
1053 | 1054 | | |
1054 | 1055 | | |
| 1056 | + | |
1055 | 1057 | | |
1056 | 1058 | | |
1057 | 1059 | | |
| |||
1097 | 1099 | | |
1098 | 1100 | | |
1099 | 1101 | | |
| 1102 | + | |
1100 | 1103 | | |
1101 | 1104 | | |
1102 | 1105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
3285 | 3286 | | |
3286 | 3287 | | |
3287 | 3288 | | |
| 3289 | + | |
3288 | 3290 | | |
3289 | 3291 | | |
3290 | 3292 | | |
| |||
3555 | 3557 | | |
3556 | 3558 | | |
3557 | 3559 | | |
| 3560 | + | |
3558 | 3561 | | |
3559 | 3562 | | |
3560 | 3563 | | |
| |||
3683 | 3686 | | |
3684 | 3687 | | |
3685 | 3688 | | |
| 3689 | + | |
3686 | 3690 | | |
3687 | 3691 | | |
3688 | 3692 | | |
| |||
3981 | 3985 | | |
3982 | 3986 | | |
3983 | 3987 | | |
| 3988 | + | |
| 3989 | + | |
| 3990 | + | |
| 3991 | + | |
3984 | 3992 | | |
3985 | 3993 | | |
3986 | 3994 | | |
| |||
4043 | 4051 | | |
4044 | 4052 | | |
4045 | 4053 | | |
4046 | | - | |
| 4054 | + | |
| 4055 | + | |
4047 | 4056 | | |
4048 | 4057 | | |
4049 | 4058 | | |
| |||
4181 | 4190 | | |
4182 | 4191 | | |
4183 | 4192 | | |
4184 | | - | |
| 4193 | + | |
| 4194 | + | |
4185 | 4195 | | |
4186 | 4196 | | |
4187 | 4197 | | |
| |||
0 commit comments