Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Recursive Complex Types #290

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

jpattersonz
Copy link
Contributor

Deal with recursive data types in the model binder config compiler and query builder. If the type is already on the query builder stack, then skip it.

@lance-wynn-cireson
Copy link

lance-wynn-cireson commented Apr 28, 2017

Thanks for this, I ran into this issue a few days after your PR. however, I did need to make a modification for my purposes as your solution only allowed for deserialization to 1 level deep. Any additional child entities were ignored. This is the change I made, it allows 10 instances of the elementType to be present before it flags it as existing.
stackContainsType: function (elementType) { //allow the stack to contain 10 of any given type to allow for deeper, but not infinite recursion. var typeCount = this._binderConfigPropertyStack .map(p => p.$type) .filter(function (x) { return x == elementType }) .length; return typeCount > 10;

@jpattersonz
Copy link
Contributor Author

Interesting, it sounds like the logic in stackContainsType has a flaw. My intent was to not recurse into a type which we already processed, but I suppose the logic should really be that we don't recurse into a Property that we have already processed. If I get some time, I'll take a look at this. Perhaps one of the core JayData developers can provide more insight.

@lance-wynn-cireson
Copy link

I think the problem may be that the queryBuilder builds out the graph first, and then applies the incoming data, which is why it gets a infinite recursion if a type repeats itself, and also why it stops resolving child elements after the end depth of the queryBuilder graph is reached.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants