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

System.ArgumentException when reading an array field with a composite type consisting of an enum based domain #2278

Open
arcaartem opened this Issue Jan 2, 2019 · 0 comments

Comments

Projects
None yet
2 participants
@arcaartem
Copy link

arcaartem commented Jan 2, 2019

Steps to reproduce

I've created a self-contained project to reproduce the issue:

https://github.com/arcaartem/postgres-npgsql-composite-type-test

The issue

Reading a column of an array of a composite type with domain members fails with an exception. One of the member types of the composite is a domain type with a base type of enum. It's only when reading where the issue is and writes to the column works as expected.

Exception raised here: https://github.com/arcaartem/postgres-npgsql-composite-type-test/blob/master/postgres-npgsql-composite-type-test/PlaceRepository.cs#L54

Exceptions details (message and stack trace).

Unhandled Exception: System.ArgumentException: Object of type 'System.String' cannot be converted to type 'composite_type_test.Language'.
   at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
   at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
   at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
   at Npgsql.TypeHandlers.UnmappedCompositeHandler.Read[TAny](NpgsqlReadBuffer buf, Int32 len, Boolean async, FieldDescription fieldDescription) in C:\projects\npgsql\src\Npgsql\TypeHandlers\UnmappedCompositeHandler.cs:line 100
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Npgsql.TypeHandling.NpgsqlTypeHandler.ReadWithLength[TAny](NpgsqlReadBuffer buf, Boolean async, FieldDescription fieldDescription) in C:\projects\npgsql\src\Npgsql\TypeHandling\NpgsqlTypeHandler.cs:line 112
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Npgsql.TypeHandlers.ArrayHandler`1.ReadList[T](NpgsqlReadBuffer buf, Boolean async) in C:\projects\npgsql\src\Npgsql\TypeHandlers\ArrayHandler.cs:line 171
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Npgsql.TypeHandlers.ArrayHandler`1.Read[TAny](NpgsqlReadBuffer buf, Int32 len, Boolean async, FieldDescription fieldDescription) in C:\projects\npgsql\src\Npgsql\TypeHandlers\ArrayHandler.cs:line 84
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Npgsql.TypeHandlers.ArrayHandler`1.Read[TAny](NpgsqlReadBuffer buf, Int32 len, FieldDescription fieldDescription) in C:\projects\npgsql\src\Npgsql\TypeHandlers\ArrayHandler.cs:line 76
   at Npgsql.NpgsqlDefaultDataReader.GetFieldValue[T](Int32 column) in C:\projects\npgsql\src\Npgsql\NpgsqlDefaultDataReader.cs:line 98
   at composite_type_test.PlaceRepository.MapCurrentRowToPlace(NpgsqlDataReader reader) in /Users/aartem/git/postgres-npgsql-composite-type-test/postgres-npgsql-composite-type-test/PlaceRepository.cs:line 51
   at composite_type_test.PlaceRepository.GetAllPlaces() in /Users/aartem/git/postgres-npgsql-composite-type-test/postgres-npgsql-composite-type-test/PlaceRepository.cs:line 30
   at composite_type_test.Program.Main() in /Users/aartem/git/postgres-npgsql-composite-type-test/postgres-npgsql-composite-type-test/Program.cs:line 27

Further technical details

Npgsql version: 4.0.4
PostgreSQL version: 10.6
Operating system: MacOS High Sierra 10.13.6

Other details about my project setup:

  • Requires Docker

@YohDeadfall YohDeadfall self-assigned this Jan 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment