efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Json Columns initial work

Open maumar opened this issue 3 years ago • 9 comments
trafficstars

Finished work:

  • basic metadata,
  • property/navigation access translation,
  • materialization (entity, collection, with nesting),
  • honoring json property name attribute for custom naming
  • validation,

Remaining work:

  • migration,
  • update,
  • collections of primitives,
  • array access/operations (force non-tracking!)
  • some metadata fixes (e.g. using actual type mapping for properties mapped to json, rather than default mappings), flowing json type info (npgsql),
  • custom serialization (???),
  • lots of fixes, cleanups, documentation,
  • testing (WIP)

blocked:

  • json owned entity having navigation to non-owned entity
  • json collection with ordinal key explicitly defined
  • inheritance (apart from TPH)
  • table splitting

maumar avatar Jun 07 '22 00:06 maumar

When you add validation also throw if an entity type is mapped to JSON, but the principal type is not mapped to a table or view (and add a note to support this for raw SQL and function mappings in #19970 and #21627)

AndriySvyryd avatar Jun 07 '22 21:06 AndriySvyryd

Add a test to RelationalModelTest that has nested JSON types and some of the column names are the same on between levels

AndriySvyryd avatar Jun 08 '22 00:06 AndriySvyryd

Requires actual query tests.

Why don't we not allow projection member binding for JsonEntityExpression?

smitpatel avatar Jun 08 '22 00:06 smitpatel

Are we planning to support navigations from inside the JSON document outside and vice versa? If so, I didn't think this would be part of a 1st version - it certainly hasn't been requested on the PG side (and sounds complicated).

It came up yesterday and we need to have a nice design meeting discussion about it

smitpatel avatar Jun 15 '22 15:06 smitpatel

Add validation for not allowing JSON column for TPT/TPC

smitpatel avatar Jun 23 '22 18:06 smitpatel

👍

ajcvickers avatar Jun 24 '22 18:06 ajcvickers

    private readonly IDictionary<ParameterExpression, IDictionary<IProperty, int>> _materializationContextBindings

can make these all dictionaries concrete Dictionary type?


Refers to: src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs:133 in b40e728. [](commit_id = b40e7283c5f6382b7b5d062fc75d0f8019043d37, deletion_comment = False)

smitpatel avatar Jun 29 '22 17:06 smitpatel

    var isTph = entityType.FindDiscriminatorProperty() != null;

@AndriySvyryd can we just use mapping strategy method now?


Refers to: src/EFCore.Relational/Metadata/Internal/RelationalModel.cs:364 in d0f43e3. [](commit_id = d0f43e38a4e320169e272647f08526532e9c8be9, deletion_comment = False)

smitpatel avatar Jun 30 '22 16:06 smitpatel

@AndriySvyryd can we just use mapping strategy method now?

Yes

AndriySvyryd avatar Jun 30 '22 16:06 AndriySvyryd

Is this draft ready for review yet? So we can really start commenting

AndriySvyryd avatar Aug 12 '22 21:08 AndriySvyryd

                earlierClientProjectionCount = _clientProjections.Count;

This is where we do process after lifting from single result subquery. Recompute the dedupe map here from this point to end point.


Refers to: src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs:846 in f2ab2b9. [](commit_id = f2ab2b9ba510d47ab49e39f8d4b325cfd19873ae, deletion_comment = False)

smitpatel avatar Aug 15 '22 20:08 smitpatel

cc: @AndriySvyryd to review metadata/update pipeline changes.

smitpatel avatar Aug 15 '22 21:08 smitpatel