Skip to content

Fix reading numerics as BigInteger#6385

Merged
vonzshik merged 2 commits intomainfrom
6383-read-numeric-as-biginteger-fix
Dec 23, 2025
Merged

Fix reading numerics as BigInteger#6385
vonzshik merged 2 commits intomainfrom
6383-read-numeric-as-biginteger-fix

Conversation

@vonzshik
Copy link
Contributor

Fixes #6383

@vonzshik vonzshik requested a review from roji as a code owner December 22, 2025 08:21
var scale = reader.ReadInt16();
var array = digits.Array!;
for (var i = digits.Offset; i < array.Length; i++)
for (var i = 0; i < digits.Count; i++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it reads a bit better like this, but up to you.

Suggested change
for (var i = 0; i < digits.Count; i++)
for (var i = digits.Offset; i < digits.Offset + digits.Count; i++)

On 9.0 and up we can use a foreach, as that's not available on netfx.

@vonzshik vonzshik enabled auto-merge (squash) December 23, 2025 07:59
@vonzshik vonzshik merged commit 381b0fa into main Dec 23, 2025
33 of 37 checks passed
@vonzshik vonzshik deleted the 6383-read-numeric-as-biginteger-fix branch December 23, 2025 09:20
vonzshik added a commit that referenced this pull request Dec 23, 2025
Fixes #6383

(cherry picked from commit 381b0fa)
vonzshik added a commit that referenced this pull request Dec 23, 2025
Fixes #6383

(cherry picked from commit 381b0fa)
vonzshik added a commit that referenced this pull request Dec 23, 2025
Fixes #6383

(cherry picked from commit 381b0fa)

# Conflicts:
#	test/Npgsql.Tests/Types/NumericTests.cs
@vonzshik
Copy link
Contributor Author

vonzshik commented Dec 23, 2025

Backported to 10.0.2 via d16098e, 9.0.5 via 603024f, 8.0.9 via 079c3b4

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.

NpgsqlBinaryExporter function throws exception when reading BigInteger.

2 participants