Fix #577 #716

Merged
merged 1 commit into from Dec 10, 2012

Projects

None yet

3 participants

@jails
Collaborator
jails commented Dec 8, 2012

To avoid indexation to be saved in the database, DocumentSet will no more be indexed if its parent is not nullon a ::data() call.

For a full indexation use :

$elem->to('array');

For no indexation at all :

$elem->to('array', array('indexed' => false);
@michaelhue

As discussed in #li3 it should be noted that this breaks reaching into arrays with keyed subdocuments via their key.

For example, given the following schema:

array(
    '_id' => 'id',
    'name' => 'string',
    'children' => array('type' => 'object', 'array' => true),
    'children._id' => 'id',
    'children.name' => 'string'
)

You could reach into the children array with their IDs:

$entity->children->{'50bbc39d8ead0ef94d000003'}->name

I think this behavior is pretty handy because if you build a schema like this you most likely want to reference the child objects in another model. This makes it easy to fetch or modify the referenced subdocument. With the changes in this commit this is no longer possible.

Maybe we should find a way to preserve this functionality while fixing the issue? Was this even a feature or a positive side-effect of the issue? What do you guys think?

@jails
Collaborator
jails commented Dec 9, 2012

Since this PR concern only the ::data() exporting step, you will be able to access childrens using their ids like before:

$entity->children['50bbc39d8ead0ef94d000003']->name

I'm not sure DocumentSet support the -> notation.

@michaelhue

In that case, nervermind. Seems that I misunderstood you yesterday, thanks for the fix. :)

@nateabele nateabele merged commit c9dcdaa into UnionOfRAD:dev Dec 10, 2012

1 check passed

Details default The Travis build passed
@jails jails referenced this pull request Dec 10, 2012
Merged

Fix #577 #720

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment