Commit 9eb92ed
authored
FEAT: Support correct type handling of None parameters in parameter binding (#208)
### Work Item / Issue Reference
<!--
IMPORTANT: Please follow the PR template guidelines below.
For mssql-python maintainers: Insert your ADO Work Item ID below (e.g.
AB#37452)
For external contributors: Insert Github Issue number below (e.g. #149)
Only one reference is required - either GitHub issue OR ADO Work Item.
-->
<!-- mssql-python maintainers: ADO Work Item -->
>
[AB#38339](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/38339)
<!-- External contributors: GitHub Issue -->
> GitHub Issue: #<ISSUE_NUMBER>
-------------------------------------------------------------------
### Summary
<!-- Insert your summary of changes below. Minimum 10 characters
required. -->
This pull request adds support for using the `SQLDescribeParam` ODBC API
to determine the correct SQL type for parameters with unknown types
(such as `None` values), improving parameter binding accuracy—especially
for binary columns. The changes include adding the necessary function
pointer, loading it from the driver, and updating the parameter binding
logic to call `SQLDescribeParam` when needed.
**ODBC API Integration:**
* Added the `SQLDescribeParamFunc` typedef and declared/defined the
`SQLDescribeParam_ptr` function pointer to enable calling
`SQLDescribeParam` from the driver.
[[1]](diffhunk://#diff-85167a2d59779df18704284ab7ce46220c3619408fbf22c631ffdf29f794d635R132-R133)
[[2]](diffhunk://#diff-85167a2d59779df18704284ab7ce46220c3619408fbf22c631ffdf29f794d635R177-R178)
[[3]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1R139-R140)
[[4]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1R820-R821)
[[5]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1L801-R832)
**Parameter Binding Improvements:**
* Updated the logic in `BindParameters` to call `SQLDescribeParam` for
parameters with unknown types, ensuring correct SQL type, column size,
and decimal digits are used for `None` values and improving support for
binary columns.
**Minor Cleanups:**
* Removed a TODO comment in `_map_sql_type` as type detection is now
handled more robustly.
<!--
### PR Title Guide
> For feature requests
FEAT: (short-description)
> For non-feature requests like test case updates, config updates ,
dependency updates etc
CHORE: (short-description)
> For Fix requests
FIX: (short-description)
> For doc update requests
DOC: (short-description)
> For Formatting, indentation, or styling update
STYLE: (short-description)
> For Refactor, without any feature changes
REFACTOR: (short-description)
> For release related changes, without any feature changes
RELEASE: #<RELEASE_VERSION> (short-description)
### Contribution Guidelines
External contributors:
- Create a GitHub issue first:
https://github.com/microsoft/mssql-python/issues/new
- Link the GitHub issue in the "GitHub Issue" section above
- Follow the PR title format and provide a meaningful summary
mssql-python maintainers:
- Create an ADO Work Item following internal processes
- Link the ADO Work Item in the "ADO Work Item" section above
- Follow the PR title format and provide a meaningful summary
-->1 parent 940597e commit 9eb92ed
File tree
3 files changed
+42
-7
lines changed- mssql_python
- pybind
3 files changed
+42
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
| 234 | + | |
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
143 | 145 | | |
144 | 146 | | |
145 | 147 | | |
| |||
212 | 214 | | |
213 | 215 | | |
214 | 216 | | |
215 | | - | |
| 217 | + | |
216 | 218 | | |
217 | 219 | | |
218 | 220 | | |
219 | 221 | | |
220 | | - | |
| 222 | + | |
221 | 223 | | |
222 | 224 | | |
223 | 225 | | |
| |||
283 | 285 | | |
284 | 286 | | |
285 | 287 | | |
286 | | - | |
287 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
288 | 312 | | |
289 | 313 | | |
290 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
291 | 319 | | |
292 | 320 | | |
293 | 321 | | |
| |||
767 | 795 | | |
768 | 796 | | |
769 | 797 | | |
| 798 | + | |
| 799 | + | |
770 | 800 | | |
771 | 801 | | |
772 | 802 | | |
| |||
777 | 807 | | |
778 | 808 | | |
779 | 809 | | |
780 | | - | |
| 810 | + | |
| 811 | + | |
781 | 812 | | |
782 | 813 | | |
783 | 814 | | |
| |||
1072 | 1103 | | |
1073 | 1104 | | |
1074 | 1105 | | |
1075 | | - | |
| 1106 | + | |
1076 | 1107 | | |
1077 | 1108 | | |
1078 | 1109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
214 | 216 | | |
215 | 217 | | |
216 | 218 | | |
| |||
257 | 259 | | |
258 | 260 | | |
259 | 261 | | |
| 262 | + | |
| 263 | + | |
260 | 264 | | |
261 | 265 | | |
262 | 266 | | |
| |||
0 commit comments