microsoft / microsoft/mssql-rs
Reconcile xml type mapping between SQLDescribeCol (SQL_WLONGVARCHAR) and SQLDescribeParam (SQL_SS_XML)
- Dominant language
- Rust
- Stars
- 53
- Forks
- 14
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 137
Description
## Problem
The driver reports two different ODBC type codes for `xml` depending on whether it is described as a **column** or as a **parameter**:
| Path | Source | Reports |
|---|---|---|
| `SQLDescribeCol` | `mssql-odbc/src/api/describe_col.rs:212` | `SQL_WLONGVARCHAR` (-10) |
| `SQLDescribeParam` | `mssql-odbc/src/api/describe_param.rs:449` | `SQL_SS_XML` (-152) |
An application that describes the same `xml` expression as a parameter and as a result column sees `-152` for one and `-10` for the other.
## Background
Raised by @David-Engel while reviewing #326 (`SQLDescribeParam`), who confirmed against SQL Server 2025 RTM-CU1 (17.0.4006) that `xml` really does arrive as TDS type id 241 from `sp_describe_undeclared_parameters`, so the `SQLDescribeParam` side is exercised in practice.
Both sides are deliberate in isolation:
- `describe_param.rs` maps to `SQL_SS_XML` because that is the SQL Server-specific ODBC type msodbcsql reports for an `xml` parameter.
- `describe_col.rs:212` maps `Xml | Json` to `SQL_WLONGVARCHAR`. This predates #326 (commit `5d375af`) and is **not** a regression from it.
Neither was changed by #326; the divergence only became visible because that PR added the parameter side.
## Why file it
Nothing is broken today, but the inconsistency is the kind that gets discovered by an application rather than by us. The two paths should agree, or the difference should be a documented, cited deviation the way other msodbcsql parity decisions in `mssql-odbc/docs/` are.
## Suggested work
1. Check what msodbcsql reports for an `xml` **column** via `SQLDescribeCol`, and cite it (the repo's ODBC rules require parity calls to cite the msodbcsql source and state whether we match, exceed, or diverge).
2. Reconcile the two mappings, or record the divergence with its justification.
3. Consider `json` at the same time: it is mapped to `SQL_WLONGVARCHAR` on both paths, so it is currently consistent — but any change to the `xml` column mapping likely touches the same match arm.
## Note
`sp_describe_undeclared_parameters` does not currently emit distinct type ids for `json` or `vector(n)` — both come back as `varchar(max)` (id 167) on 17.0.4006 — so only `xml` is observably divergent today.
Contributor guide
Research direction
Start with mssql-odbc/src/api/describe_col.rs:212 and mssql-odbc/src/api/describe_param.rs:449, then verify what msodbcsql reports for an xml column through SQLDescribeCol. Review the parity guidance and related decisions in mssql-odbc/docs/. Done means the mappings agree, or the documented divergence includes a citation and justification, with json still considered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100