◐ Shell
clean mode source ↗

Fix off-by-one in ThrowColumnMismatch exception message by BrunoSync · Pull Request #6584 · npgsql/npgsql

Fixes #6583

Problem

ThrowColumnMismatch was using _column + 1 in the exception message,
but _column already holds the correct number of values written when the
method is called from StartRow. This caused the reported value count to
always be off by one.

For example, with a 3-column table where only 2 values were written:

"started with 3 column(s), but 3 value(s) were provided"

when it should say:

"started with 3 column(s), but 2 value(s) were provided"

Fix

Removed the + 1 from the interpolated string in ThrowColumnMismatch.

Test

Added Write_column_out_of_bounds_exception_message to CopyTests.cs
to verify the exception message reports the correct value count.