The `'joined'` strategy now lazy load primary keys when needed. #753

Merged
merged 1 commit into from Dec 19, 2012

Conversation

Projects
None yet
2 participants
Contributor

jails commented Dec 19, 2012

When the 'joined' strategy is used, all primary keys of relations are automagically added to the query to allow a correct hydratation of nested entities. However this strategy pollute the result with extra datas.

previously:

Images::find('all',
    'fields' => array('Image'),
    'with' => array('ImagesTags.Tags'),
    'conditions' => array('Tags.name' => 'flower')
);

produce:

array(
    0 => array(
        'id' => 5,
        'name' => 'Tulip',
        'images_tags' => array(
            0=> array(
                'id' => 1
                'tags' => array(
                    'id' => 2
                )
            )
            /*...and so on....*/
        )
    )
    /*...and so on....*/

Since 'fields' => array('Image') is defined, the hydratation up to Tags is not necessary.

This PR allow to produce results with less "polluting datas".

nateabele added a commit that referenced this pull request Dec 19, 2012

Merge pull request #753 from jails/pr12
The `'joined'` strategy now lazy load primary keys when needed.

@nateabele nateabele merged commit c0a3e2b into UnionOfRAD:dev Dec 19, 2012

1 check passed

default The Travis build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment