Breeze / breeze.server.net

Breeze support for .NET servers
MIT License
76 stars 62 forks source link

Persistence Core has arbitrary incompatibility with Angular 7 during Migration from 3.x to 5.0 #121

Closed Prinsn closed 3 years ago

Prinsn commented 3 years ago

Migrating from .NET 3.x to 5.x, our application is suddenly failing in a strange way that is hard to diagnose, but the error only occurs when upgrading the Persistence Manager to 5.x.

When querying the backend with some entities of some depth, in breeze.debug.js

 // This method is called when an EntityAspect is first created - this will occur as part of the entityType.createEntity call.
  // which can be called either directly or via standard query materialization

  // entity is either an entity or a complexObject
  protoFn.startTracking = function (entity, proto) {
    // can't touch the normal property sets within this method - access the backingStore directly instead.
    var bs = movePropsToBackingStore(entity);

    // assign default values to the entity
    var stype = entity.entityType || entity.complexType;
    stype.getProperties().forEach(function (prop) {

      var propName = prop.name;
      var val = entity[propName];

      if (prop.isDataProperty) {
        if (prop.isComplexProperty) {
          if (prop.isScalar) {
            val = prop.dataType._createInstanceCore(entity, prop);
          } else {
            val = breeze.makeComplexArray([], entity, prop);
          }
        } else if (!prop.isScalar) {
          val = breeze.makePrimitiveArray([], entity, prop);
        } else if (val === undefined) {
          val = prop.defaultValue;
        }

      } else if (prop.isNavigationProperty) {
        if (val !== undefined) {
          throw new Error("Cannot assign a navigation property in an entity ctor.: " + propName);

Throwing at the truncating point, as the navigation property is null

For existing, function entities, we're getting failures, but existing entities work fine.

The issue, as far as I can trace it down, is that during a query of the data, it is trying to create a new object

createdByUser: null
createdByUserId: ""
createdDate: Mon Jan 01 1900 00:00:00 GMT-0500 (Eastern Standard Time)
description: ""
discriminator: ""
entityAspect: EntityAspect {entity: myEntityCtor, entityGroup: null, entityManager: null, entityState: EnumSymbol, isBeingSaved: false, …}
hasVotingRights: null
id: 0
modifiedByUser: null
modifiedByUserId: null
modifiedDate: null
participationThreshold: null
projectionEntity: null
projectionEntityId: 0

Quick check of other entities passing through this are all undefined across every property

This behavior is extremely unexpected, and is literally a breaking change, and since it's a front end problem created by a back end change, it's exceedingly difficult to actually isolate.

Attempting to upgrade to breeze-client 2.x has proven unsuccessful as it will not compile with angular, so uncertain if that is the expected fix

steveschmitt commented 3 years ago

Can you show the json that is retrieved from the server?

Prinsn commented 3 years ago

I'm not sure how much I can, due to proprietary whatever, but I'm not certain it's not metadata related.

I'm testing around the app to see what does still function, as creating a new entity in some places that has unpopulated navigational properties is not causing problems, and I can create some entities, but other entities are failing during creation steps of the following code.

    constructor(
        private entityManagerProvider: EntityManagerProviderService,

    private manager(): EntityManager {
        return this.entityManagerProvider.manager();
    }

    createEntity(config?: Partial<T>): T {
        const e = <T>this.manager().createEntity(this.entityTypeName, config);

When failing, it fails in the same manner.

I'm conferring about what I can submit regarding to the requested return.

Prinsn commented 3 years ago

Also, random hunch:

A common failure appears to be that the entity in question is a Table Per Hierarchy entity. I don't know if this is at all informative or useful.

Prinsn commented 3 years ago

Can you show the json that is retrieved from the server?

@steveschmitt Removed

Prinsn commented 3 years ago

@steveschmitt Is it possible to remove a reference to the prior file, was asked to clean up some data.

Also I've been given permission to share other data for diagnostics but not on public forum, is there a professional contact with ideablade that I could reach out to?

Prinsn commented 3 years ago

Sanitized reupload response.json.txt

steveschmitt commented 3 years ago

My ideablade.com email name is steves

Prinsn commented 3 years ago

I have sent an email to steves at that domain, as jmmiller from bdo.

As I am on the free subscription I understand if I do not receive timely responses, and you can continue to prompt through this issue (so as to better facilitate other people that need help with such an issue coming in from searches) but that will likely be how I am going to be required to convey any sensitive details.

Prinsn commented 3 years ago

Per initial testing, Persistence 5.0.4 appears to have fixed this 🙏