enum doesn't work with npgsql on bulkcopy
See original GitHub issuewhen trying to bulk copy a list of entities containing Enum parameters (that are represented by enum in postgres) i’m getting this message. (here for the enum currency)
Npgsql.PostgresException (0x80004005): 42804: column "currency" is of type currency but expression is of type integer
at void Npgsql.NpgsqlConnector+<>c__DisplayClass160_0+<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext()
at void Npgsql.NpgsqlConnector+<>c__DisplayClass160_0+<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext()
at async Task<bool> Npgsql.NpgsqlDataReader.NextResult(bool async, bool isConsuming)
at bool Npgsql.NpgsqlDataReader.NextResult()
at async ValueTask<NpgsqlDataReader> Npgsql.NpgsqlCommand.ExecuteReaderAsync(CommandBehavior behavior, bool async, CancellationToken cancellationToken)
at async Task<int> Npgsql.NpgsqlCommand.ExecuteNonQuery(bool async, CancellationToken cancellationToken)
at int Npgsql.NpgsqlCommand.ExecuteNonQuery()
at int LinqToDB.Data.DbCommandProcessor.DbCommandProcessorExtensions.ExecuteNonQueryExt(IDbCommand cmd)
at int LinqToDB.Data.DataConnection.ExecuteNonQuery(IDbCommand command)
at int LinqToDB.Data.DataConnection.ExecuteNonQuery()
at int LinqToDB.Data.CommandInfo.Execute()
at int LinqToDB.Data.DataConnectionExtensions.Execute(DataConnection connection, string sql, DataParameter[] parameters)
at bool LinqToDB.DataProvider.MultipleRowsHelper.Execute()
at BulkCopyRowsCopied LinqToDB.DataProvider.BasicBulkCopy.MultipleRowsCopy1(MultipleRowsHelper helper, IEnumerable source)
at BulkCopyRowsCopied LinqToDB.DataProvider.BasicBulkCopy.MultipleRowsCopy1<T>(ITable<T> table, BulkCopyOptions options, IEnumerable<T> source)
at BulkCopyRowsCopied LinqToDB.DataProvider.PostgreSQL.PostgreSQLBulkCopy.MultipleRowsCopy<T>(ITable<T> table, BulkCopyOptions options, IEnumerable<T> source)
at BulkCopyRowsCopied LinqToDB.DataProvider.BasicBulkCopy.BulkCopy<T>(BulkCopyType bulkCopyType, ITable<T> table, BulkCopyOptions options, IEnumerable<T> source)
at BulkCopyRowsCopied LinqToDB.DataProvider.PostgreSQL.PostgreSQLDataProvider.BulkCopy<T>(ITable<T> table, BulkCopyOptions options, IEnumerable<T> source)
at BulkCopyRowsCopied LinqToDB.Data.DataConnectionExtensions.BulkCopy<T>(DataConnection dataConnection, BulkCopyOptions options, IEnumerable<T> source)
at BulkCopyRowsCopied LinqToDB.EntityFrameworkCore.LinqToDBForEFTools.BulkCopy<T>(DbContext context, BulkCopyOptions options, IEnumerable<T> source)
Exception data:
Severity: ERROR
SqlState: 42804
MessageText: column "currency" is of type currency but expression is of type integer
Hint: You will need to rewrite or cast the expression.
Position: 832
File: parse_target.c
Line: 591
Routine: transformAssignedExpr
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
PostgreSQL enums and composites
PostgreSQL supports enum types and composite types as database columns, and Npgsql supports reading and writing these. This allows you to seamlessly read...
Read more >npgsql says enum is not registered
I'm trying to insert some data with enums via Npgsql. At first, everything worked fine, but I have noted, that some of my...
Read more >COPY | Npgsql Documentation
COPY. PostgreSQL has a feature allowing efficient bulk import or export of data to and from a table. This is usually a much...
Read more >Dealing with Enum Type in PostgreSQL
This is a brief guide for effectively understanding and working with enum type in Postgres: Why does it exist? What does it do?...
Read more >Create a Custom SQL Enum Type
In this lesson we'll create and assign data to a custom enum type. For more info: https://www.postgresql.org/docs/9.2/sql-createtype.html; https://docs.oracle ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is more provider specific problem and i need more details.
Closing as it looks like all questions resolved.
Some extra notes:
MappingSchema.Default
with newAddMappingSchema
configuration API in latest release: you can configure separate mapping schemaGlobalTypeMapper
anymore in npgsql 7, check this issue for help