Commit 8a508b6
authored
FEAT: Complex Datatype support-XML (microsoft#293)
### 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. microsoft#149)
Only one reference is required - either GitHub issue OR ADO Work Item.
-->
<!-- mssql-python maintainers: ADO Work Item -->
>
[AB#38821](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/38821)
<!-- External contributors: GitHub Issue -->
> GitHub Issue: #<ISSUE_NUMBER>
-------------------------------------------------------------------
### Summary
<!-- Insert your summary of changes below. Minimum 10 characters
required. -->
This pull request adds comprehensive support for the SQL Server `XML`
data type to the Python MSSQL driver, ensuring proper handling for
insertion, retrieval, batching, and streaming of XML data. It also
introduces a suite of tests to verify correct XML behavior, including
edge cases like empty, large, and malformed XML values.
### MSSQL Driver Enhancements
* Added support for the `SQL_SS_XML` data type throughout the driver,
including binding, fetching, and row size calculations, so that XML
columns are handled correctly during data operations.
[[1]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1R24)
[[2]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1R2529-R2534)
[[3]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1R2992)
[[4]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1R3195-R3198)
[[5]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1R3412)
* Updated logic in `FetchMany_wrap` and `FetchAll_wrap` to treat XML
columns as LOBs, enabling efficient streaming for large XML values.
[[1]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1L3504-R3517)
[[2]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1L3626-R3639)
### Test Coverage for XML Support
* Added multiple tests in `tests/test_004_cursor.py` to verify XML
handling, including basic insert/fetch, empty/null values, large XML
streaming, batch inserts, and error handling for malformed XML input.
<!--
### 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 5a0bc59 commit 8a508b6
File tree
2 files changed
+94
-2
lines changed- mssql_python/pybind
- tests
2 files changed
+94
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
2525 | 2526 | | |
2526 | 2527 | | |
2527 | 2528 | | |
| 2529 | + | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
| 2533 | + | |
| 2534 | + | |
2528 | 2535 | | |
2529 | 2536 | | |
2530 | 2537 | | |
| |||
3395 | 3402 | | |
3396 | 3403 | | |
3397 | 3404 | | |
| 3405 | + | |
3398 | 3406 | | |
3399 | 3407 | | |
3400 | 3408 | | |
| |||
3499 | 3507 | | |
3500 | 3508 | | |
3501 | 3509 | | |
3502 | | - | |
| 3510 | + | |
3503 | 3511 | | |
3504 | 3512 | | |
3505 | 3513 | | |
| |||
3621 | 3629 | | |
3622 | 3630 | | |
3623 | 3631 | | |
3624 | | - | |
| 3632 | + | |
3625 | 3633 | | |
3626 | 3634 | | |
3627 | 3635 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11409 | 11409 | | |
11410 | 11410 | | |
11411 | 11411 | | |
| 11412 | + | |
| 11413 | + | |
| 11414 | + | |
| 11415 | + | |
| 11416 | + | |
| 11417 | + | |
| 11418 | + | |
| 11419 | + | |
| 11420 | + | |
| 11421 | + | |
| 11422 | + | |
| 11423 | + | |
| 11424 | + | |
| 11425 | + | |
| 11426 | + | |
| 11427 | + | |
| 11428 | + | |
| 11429 | + | |
| 11430 | + | |
| 11431 | + | |
| 11432 | + | |
| 11433 | + | |
| 11434 | + | |
| 11435 | + | |
| 11436 | + | |
| 11437 | + | |
| 11438 | + | |
| 11439 | + | |
| 11440 | + | |
| 11441 | + | |
| 11442 | + | |
| 11443 | + | |
| 11444 | + | |
| 11445 | + | |
| 11446 | + | |
| 11447 | + | |
| 11448 | + | |
| 11449 | + | |
| 11450 | + | |
| 11451 | + | |
| 11452 | + | |
| 11453 | + | |
| 11454 | + | |
| 11455 | + | |
| 11456 | + | |
| 11457 | + | |
| 11458 | + | |
| 11459 | + | |
| 11460 | + | |
| 11461 | + | |
| 11462 | + | |
| 11463 | + | |
| 11464 | + | |
| 11465 | + | |
| 11466 | + | |
| 11467 | + | |
| 11468 | + | |
| 11469 | + | |
| 11470 | + | |
| 11471 | + | |
| 11472 | + | |
| 11473 | + | |
| 11474 | + | |
| 11475 | + | |
| 11476 | + | |
| 11477 | + | |
| 11478 | + | |
| 11479 | + | |
| 11480 | + | |
| 11481 | + | |
| 11482 | + | |
| 11483 | + | |
| 11484 | + | |
| 11485 | + | |
| 11486 | + | |
| 11487 | + | |
| 11488 | + | |
| 11489 | + | |
| 11490 | + | |
| 11491 | + | |
| 11492 | + | |
| 11493 | + | |
| 11494 | + | |
| 11495 | + | |
11412 | 11496 | | |
11413 | 11497 | | |
11414 | 11498 | | |
| |||
0 commit comments