Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override ValueTask<BigInteger> ReadAsync(PgReader reader, CancellationTok
{
// If we don't need a read and can read buffered we delegate to our sync read method which won't do IO in such a case.
if (!reader.ShouldBuffer(reader.CurrentRemaining))
Read(reader);
return new(Read(reader));

return AsyncCore(reader, cancellationToken);

Expand Down
27 changes: 27 additions & 0 deletions test/Npgsql.Tests/BugTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using NUnit.Framework;
using System;
using System.Data;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -1391,4 +1392,30 @@ public async Task Bug4123()
Assert.DoesNotThrowAsync(stream.FlushAsync);
Assert.DoesNotThrow(stream.Flush);
}

[Test, IssueLink("https://github.com/npgsql/npgsql/issues/6389")]
public async Task Composite_with_BigInteger([Values(CommandBehavior.Default, CommandBehavior.SequentialAccess)] CommandBehavior behavior)
{
await using var adminConnection = await OpenConnectionAsync();
var type = await GetTempTypeName(adminConnection);
await adminConnection.ExecuteNonQueryAsync($"CREATE TYPE {type} as (value numeric)");

var dataSourceBuilder = CreateDataSourceBuilder();
dataSourceBuilder.MapComposite<Composite_with_BigInteger_Composite>(type);
await using var dataSource = dataSourceBuilder.Build();
await using var connection = await dataSource.OpenConnectionAsync();

await using var cmd = connection.CreateCommand();
cmd.CommandText = $"SELECT ROW(1234567890::numeric)::{type} FROM generate_series(1, 8000)";
await using var reader = await cmd.ExecuteReaderAsync(behavior);
while (await reader.ReadAsync())
{
Assert.DoesNotThrowAsync(async () => await reader.GetFieldValueAsync<Composite_with_BigInteger_Composite>(0));
}
}

class Composite_with_BigInteger_Composite
{
public BigInteger Value { get; set; }
}
}
Loading