Skip to content

Clear stale column values before deserialization reads - #2276

Open
tuncaypeker wants to merge 1 commit into
DapperLib:mainfrom
tuncaypeker:fix/column-error-diagnostics
Open

tuncaypeker wants to merge 1 commit into
DapperLib:mainfrom
tuncaypeker:fix/column-error-diagnostics

Conversation

@tuncaypeker

Copy link
Copy Markdown

Fixes #1323.

When a provider throws while reading a column, the deserializer has already recorded that column's index but may still hold the previous column's value for diagnostics. The resulting DataException names the failing column and shows a value from a different column.

Clear the object diagnostic local before each mapped column is read. A value successfully read from the current column is still retained for conversion or setter errors, including the unboxed GetFieldValue path. This adds no public API or dependencies.

Validation:

  • Reproduced on unmodified upstream main at 1880947 with a provider-independent fake reader: both property mapping and constructor mapping show the previous column's sentinel value in the second column's error. Both regression cases fail; a current-value conversion-error control passes.
  • Five regression cases cover property and constructor read failures, a mixed GetValue/GetFieldValue read failure, and controls retaining the current value on conversion and typed-setter failures.
  • The regression and existing type-mapping tests pass on net10.0: 18 passed.
  • No real MySQL reproduction was performed; the reader fault is simulated directly at the provider API boundary.
  • Selected column-diagnostic, type-mapping, reader, constructor, multi-map, null, type-handler, SQLite, date/time, and enum tests pass on net481 (178), net8.0 (187), and net10.0 (187), with no skips or failures. SQL Server tests use SQL Server 2025 LocalDB and both SqlClient providers.
  • The full repository test suite was not run.
  • Release library build succeeds for net461, netstandard2.0, net8.0, and net10.0 with zero warnings or errors.

This branch has not been deployed

No deployments
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.

Error parsing column {index} ({name}={formattedValue}) has wrong formattedValue

1 participant