fix(sqlgetdata): read large NVARCHAR/VARBINARY correctly via incremental SQLGetData #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR: fix(sqlgetdata): read large NVARCHAR/VARBINARY correctly via incremental SQLGetData fix #12
Summary
Fix corrupted strings returned by the Dart ODBC binding when drivers return column data in chunks. Implement incremental reads for SQLGetData and correct byte/unit handling for wide chars and binaries.
Problem
Some ODBC drivers (notably SQL Server) return column data in multiple parts. The previous implementation:
This led to garbage bytes inside Dart strings.
Fix
SQLGetDatauntil the driver signals completion (handle partial reads).SQLGetData.SQL_C_BINARYand read into aUint8List.sizeof(Uint16).SQL_NULL_DATA, avoid double-free and fix memory handling.Files changed
lib/src/dart_odbc_base.dart— incremental-read logic, byte/UTF‑16 handling, memory fixes.test/incremental_sqlgetdata_test.dart— integration test that reads a long NVARCHAR and asserts no long runs of non-printable characters.Test (local)
example/.envdart pub get dart test test/incremental_sqlgetdata_test.dart -r expanded