mutualmobile/MMRecord — pull request #60 by andreacremaschi (2014-04-08 09:49:58+00:00)
Title: Representations that allows relationships between entities of the same kind

Hi again,

I have encountered another usage scenario that I thought it would work and it didn't..
It has to do with entities that can hold relationships to entity of their same kind (i.e. pages that link to subpages). In this scenario the correct reconstruction of the object graph depends on the order in which the objects representations appear.

Let's say we have a representation where objects and relationships are represented in this way and this precise order:

```
1. A -> B, C
2. B
3. C
```

In the representation, every row contains an object representation and a representation of its relationships (let's say an array of ids).
What happens is that B and C proto records are first created when A is being parsed. When the parser consider row 2 it finds that B already exists in the ```recordResponseGroup```, so it passes over. The issue here is that ```proto.dictionary``` now contains only the id of the object and not the full representation, and the marshaler will use this object representation instead of the full one present in row 2.

Of course the code works correctly if the representation is ordered like this:

```
1. B
2. C
3. A -> B, C
```

The solution proposed in my PR checks the number of records in each representation and keeps the richest one. Is it too inelegant?