npgsql / efcore.pg

Entity Framework Core provider for PostgreSQL
PostgreSQL License
1.59k stars 227 forks source link

Implement or block JSON primitive collections #2860

Open roji opened 1 year ago

roji commented 1 year ago

EFCore.PG has its own rich support for mapping primitive collections to PG arrays (and multiranges, and geometry collections...). However, users can still elect to define the store type as string, triggering the general EF relational support for JSON primitive collections. This currently fails because the query pipeline doesn't support it: TranslatePrimitiveCollection assumes that the list is an array and applies unnest on it, which fails on strings.

We can either implement this, or at the very least block it in our type mapping.

Note that test Join_local_collection_int_closure_is_cached_correctly is related to this. It currently fails because it has a scenario that's currently unsupported (value converter with a non-array/list collection type. Because of this, it falls back to the relational JSON primitive collection, which fails.

Note that this is related to but distinct from primitive collections inside JSON document (owned entities), where PG arrays don't make sense and JSON collections have to be used regardless. This issue is about primitive collections which aren't in a JSON column.

roji commented 1 year ago

Putting in the backlog, please upvote this if your interested in mapping .NET collections to JSON arrays (as opposed to PostgreSQL arrays, which is what the provider does now).