Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk operation fails when owned type has enum member on PostgreSQL #1517

Open
cervengoc opened this issue Jun 11, 2024 · 0 comments
Open

Bulk operation fails when owned type has enum member on PostgreSQL #1517

cervengoc opened this issue Jun 11, 2024 · 0 comments

Comments

@cervengoc
Copy link

cervengoc commented Jun 11, 2024

Hi,

Please have a look at the test in my fork, which passes for MSSql but failes for PostgreSQL.
cervengoc@719e243

Exception details:

Writing values of 'EFCore.BulkExtensions.Tests.Owned.EnumType' is not supported for parameters having DataTypeName 'integer'.
   at Npgsql.Internal.AdoSerializerHelpers.<GetTypeInfoForWriting>g__ThrowWritingNotSupported|1_0(Type type, PgSerializerOptions options, Nullable`1 pgTypeId, Nullable`1 npgsqlDbType, Exception inner)
   at Npgsql.Internal.AdoSerializerHelpers.GetTypeInfoForWriting(Type type, Nullable`1 pgTypeId, PgSerializerOptions options, Nullable`1 npgsqlDbType)
   at Npgsql.NpgsqlParameter.ResolveTypeInfo(PgSerializerOptions options)
   at Npgsql.NpgsqlBinaryImporter.<Write>g__Core|26_0[T](Boolean async, T value, Nullable`1 npgsqlDbType, String dataTypeName, CancellationToken cancellationToken)
   at EFCore.BulkExtensions.SqlAdapters.PostgreSql.PostgreSqlAdapter.InsertAsync[T](DbContext context, IEnumerable`1 entities, TableInfo tableInfo, Action`1 progress, Boolean isAsync, CancellationToken cancellationToken) in W:\Work\Github\EFCore.BulkExtensions\EFCore.BulkExtensions\SqlAdapters\PostgreSql\PostgreSqlAdapter.cs:line 132
   at EFCore.BulkExtensions.SqlAdapters.PostgreSql.PostgreSqlAdapter.InsertAsync[T](DbContext context, IEnumerable`1 entities, TableInfo tableInfo, Action`1 progress, Boolean isAsync, CancellationToken cancellationToken) in W:\Work\Github\EFCore.BulkExtensions\EFCore.BulkExtensions\SqlAdapters\PostgreSql\PostgreSqlAdapter.cs:line 167
   at EFCore.BulkExtensions.SqlAdapters.PostgreSql.PostgreSqlAdapter.InsertAsync[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, Action`1 progress, CancellationToken cancellationToken) in W:\Work\Github\EFCore.BulkExtensions\EFCore.BulkExtensions\SqlAdapters\PostgreSql\PostgreSqlAdapter.cs:line 31
   at EFCore.BulkExtensions.SqlAdapters.PostgreSql.PostgreSqlAdapter.MergeAsync[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, OperationType operationType, Action`1 progress, Boolean isAsync, CancellationToken cancellationToken) in W:\Work\Github\EFCore.BulkExtensions\EFCore.BulkExtensions\SqlAdapters\PostgreSql\PostgreSqlAdapter.cs:line 308
   at EFCore.BulkExtensions.SqlAdapters.PostgreSql.PostgreSqlAdapter.MergeAsync[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, OperationType operationType, Action`1 progress, Boolean isAsync, CancellationToken cancellationToken) in W:\Work\Github\EFCore.BulkExtensions\EFCore.BulkExtensions\SqlAdapters\PostgreSql\PostgreSqlAdapter.cs:line 416
   at EFCore.BulkExtensions.SqlAdapters.PostgreSql.PostgreSqlAdapter.MergeAsync[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, OperationType operationType, Action`1 progress, CancellationToken cancellationToken) in W:\Work\Github\EFCore.BulkExtensions\EFCore.BulkExtensions\SqlAdapters\PostgreSql\PostgreSqlAdapter.cs:line 232
   at EFCore.BulkExtensions.SqlBulkOperation.MergeAsync[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, OperationType operationType, Action`1 progress, CancellationToken cancellationToken) in W:\Work\Github\EFCore.BulkExtensions\EFCore.BulkExtensions\SqlBulkOperation.cs:line 74
   at EFCore.BulkExtensions.DbContextBulkTransaction.ExecuteAsync[T](DbContext context, Type type, IEnumerable`1 entities, OperationType operationType, BulkConfig bulkConfig, Action`1 progress, CancellationToken cancellationToken) in W:\Work\Github\EFCore.BulkExtensions\EFCore.BulkExtensions\DbContextBulkTransaction.cs:line 103
   at EFCore.BulkExtensions.Tests.Owned.NestedOwnedTests.NestedOwnedTest(SqlType sqlType) in W:\Work\Github\EFCore.BulkExtensions\EFCore.BulkExtensions.Tests\Owned\NestedOwnedTests.cs:line 42

If you can confirm it as a bug, is there any chance to backport the fix to 6.x branch?
While it gives somewhat a different exception message in the 6.x stack, I guess the root cause is most likely the same.

Thank you in advance.

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

No branches or pull requests

1 participant