-
Notifications
You must be signed in to change notification settings - Fork 874
Open
Description
It seems mapping for JsonNode[] is missing in from JsonTypeInfoResolverFactory:
npgsql/src/Npgsql/Internal/ResolverFactories/JsonTypeInfoResolverFactory.cs
Lines 95 to 107 in ba83963
| static TypeInfoMappingCollection AddMappings(TypeInfoMappingCollection mappings) | |
| { | |
| foreach (var dataTypeName in new[] { DataTypeNames.Jsonb, DataTypeNames.Json }) | |
| { | |
| mappings.AddArrayType<JsonDocument>(dataTypeName); | |
| mappings.AddStructArrayType<JsonElement>(dataTypeName); | |
| mappings.AddArrayType<JsonObject>(dataTypeName); | |
| mappings.AddArrayType<JsonArray>(dataTypeName); | |
| mappings.AddArrayType<JsonValue>(dataTypeName); | |
| } | |
| return mappings; | |
| } |
So invoking command with parameter:
new NpgsqlParameter() { NpgsqlDbType = NpgsqlDbType.Array | NpgsqlDbType.Jsonb, Value = (JsonNode[])[...] }throws exeption:
Type 'JsonNode[]' required dynamic JSON serialization, which requires an explicit opt-in; call 'EnableDynamicJson' on 'NpgsqlDataSourceBuilder' or NpgsqlConnection.GlobalTypeMapper
While
new NpgsqlParameter() { NpgsqlDbType = NpgsqlDbType.Array | NpgsqlDbType.Jsonb, Value = (JsonObject[])[...] }
new NpgsqlParameter() { NpgsqlDbType = NpgsqlDbType.Array | NpgsqlDbType.Jsonb, Value = (object[])[...] }works fine.
Npgsql vesion: 10.0.2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels