-
Notifications
You must be signed in to change notification settings - Fork 877
Closed
Description
Steps to reproduce
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using Npgsql;
namespace NpgsqlTest;
internal static class Program
{
private static async Task Main(string[] args)
{
await using var npgsqlConnection = new NpgsqlConnection(args[0]);
await npgsqlConnection.OpenAsync();
await using var command = npgsqlConnection.CreateCommand();
command.CommandText = "SELECT 1 = ANY($1)";
command.Parameters.Add
(
new NpgsqlParameter<ReadOnlyCollection<byte>>
{
TypedValue = new(new byte[] {1})
}
);
await command.PrepareAsync();
var result = await command.ExecuteScalarAsync();
Console.WriteLine(result);
command.Parameters.Clear();
command.Parameters.Add
(
new NpgsqlParameter<IList<byte>>
{
TypedValue = ImmutableSortedSet<byte>.Empty.Add(1)
}
);
await command.PrepareAsync();
result = await command.ExecuteScalarAsync();
Console.WriteLine(result);
}
}The issue
working Npgsql 7.0.6
not working Npgsql 8.0.0-rc.2
Exception message: System.InvalidCastException: "Writing values of 'System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Byte, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' is not supported for parameters having no NpgsqlDbType or DataTypeName. Try setting one of these values to the expected database type.."
Stack trace: in Npgsql.Internal.AdoSerializerHelpers.<GetTypeInfoForWriting>g__ThrowWritingNotSupported|1_0(Type type, String pgTypeString, Exception inner)
in Npgsql.Internal.AdoSerializerHelpers.GetTypeInfoForWriting(Type type, Nullable`1 pgTypeId, PgSerializerOptions options, Nullable`1 npgsqlDbType)
in Npgsql.NpgsqlParameter.ResolveTypeInfo(PgSerializerOptions options)
in Npgsql.NpgsqlParameterCollection.ProcessParameters(PgSerializerOptions options, Boolean validateValues, CommandType commandType)
in Npgsql.NpgsqlCommand.Prepare(Boolean async, CancellationToken cancellationToken)
in Npgsql.NpgsqlCommand.PrepareAsync(CancellationToken cancellationToken)
in NpgsqlTest.Program.<Main>d__0.MoveNext() in D:\GitRepository\NpgsqlTest\NpgsqlTest\Program.cs:строка 28
in NpgsqlTest.Program.<Main>d__0.MoveNext() in D:\GitRepository\NpgsqlTest\NpgsqlTest\Program.cs:строка 42
in NpgsqlTest.Program.<Main>d__0.MoveNext() in D:\GitRepository\NpgsqlTest\NpgsqlTest\Program.cs:строка 42
Further technical details
Npgsql version: 8.0.0-rc.2
PostgreSQL version: 14
Operating system: windows 10
Reactions are currently unavailable