New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix eager loading of relations when using parse/format #1838

Merged
merged 3 commits into from May 7, 2018

Conversation

Projects
2 participants
@ricardograca
Copy link
Member

ricardograca commented May 7, 2018

Introduction

This fixes eager loading of related models when the parent model had a custom id attribute and a parse/format method that mutated it.

Motivation

For more info check the linked issue.

Proposed solution

This just runs the parentIdAttribute through that model's parse method in order to get the parsed key that is needed for pairing the eager fetched models with their parents.

Fixes #1502.

Alternatives considered

A better approach would probably be to delay the parsing of model attributes until the very last moment before models are delivered to the user, but that would require a more extensive refactoring of the whole parse/format functionality that is better suited for a separate task later on.

ricardograca added some commits May 7, 2018

Add test to check for eager loading in some cases
- Eager loading related models is failing when the parent model has a
custom id attribute and a parse/format method that mutates it.
Fix failing eager loading in some cases
- The failure was when Eager loading related models is failing when the
parent model had a custom id attribute and a parse/format method that
mutated it.

@ricardograca ricardograca added this to To Do in Version 0.14.0 via automation May 7, 2018

@ricardograca ricardograca merged commit 13ee6f5 into master May 7, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

Version 0.14.0 automation moved this from To Do to Done May 7, 2018

@ricardograca ricardograca deleted the rg-eager-load branch May 7, 2018

@skout90

This comment has been minimized.

Copy link

skout90 commented Jun 23, 2018

@ricardograca thanks!!!!!

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