Skip to content

fix: improve QueryStream::into_results to better handle empty results. (#380) - #385

Open
rebuild1157 wants to merge 1 commit into
prisma:mainfrom
rebuild1157:patches(tds)
Open

fix: improve QueryStream::into_results to better handle empty results. (#380)#385
rebuild1157 wants to merge 1 commit into
prisma:mainfrom
rebuild1157:patches(tds)

Conversation

@rebuild1157

Copy link
Copy Markdown

fix #380

@rebuild1157
rebuild1157 marked this pull request as ready for review July 2, 2025 01:07
joelparkerhenderson added a commit to mssql-rust/mssql-rust that referenced this pull request Aug 29, 2026
Mirrors prisma/tiberius#385, fixes upstream issue #380. In a
multi-statement batch, into_results() collapsed consecutive empty (0
row) result sets into fewer entries than the number of actual SELECT
statements, so a caller had no reliable way to tell which statement in
the batch produced which (possibly empty) result.

Every QueryStream starts with metadata for its first result set (see
the type's own doc comment), so the fixed version uses that guaranteed
first item only to check whether there's a result set at all, then
counts result sets by Metadata-item boundaries rather than by whether
a Vec<Row> happens to be Some/None.

Added a regression test reproducing the exact shape from the reported
issue (three statements, two returning nothing, one returning a row) -
verified it fails against the old code (3 != 2, matching the report)
and passes against the fix, live against a real SQL Server (Azure SQL
Edge via rustls).

Verified: cargo check across all 6 CI feature combinations, cargo
clippy --all-targets, cargo fmt --check, cargo test --lib (152
passing), and the new regression test live all pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0156Di1tRRLsJK8ctU1AmAJr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

QueryStream into_result doesn't return correct number of results

1 participant