IdeaBlade/Breeze — pull request #37 by chadqueen (2014-02-27 22:00:46+00:00)
Title: Fixed Model Inheritance Property Comparison Issue

With multiple classes extending a parent class, the wrapping of property
descriptions in a recursive fashion was causing invalid property
comparisons when trying to fix up ids after a valid save response. Going
up the inheritance tree to retrieve the description forms consistent
property objects for the inheriting model.

Describing the issue found:
I had three entity model classes extending from a base class, and a registered the constructors for all three models with entityManager.metadataStore.registerEntityTypeCtor().
----------------------------------------------
Pseudocode:
registerEntityTypeCtor(modelA)
registerEntityTypeCtor(modelB)
registerEntityTypeCtor(modelC)

Load form to take input for modelA,

saveChanges()
-----------------------------------------------
The only changed entity in the entityManager is a modelA entity with entityState 'Added', it is successfully sent to the server, the server successfully saves it and responds with data for the client to fix up the entity id.

During the id fix up, the defaultPropertyInterceptor works through the logic with the single property scalar key value of id, and makes a comparison if (p === property). With the recursive implementation in wrapPropDescription(proto, property), the property comparison for modelA actually has a reference to modelC, the comparison fails and an error is thrown.

The same error occurs when saving an entity type of modelB. modelC entities do not encounter the issue, as the comparison passes.

By changing the wrapPropDescription implementation from recursive to more of a property description lookup, there are no longer any references to the last child model registered, the comparison passes, the id is fixed up based upon the server response and the issue is fixed.