Skip to content

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

Merged
ricardograca merged 3 commits into
masterfrom
rg-eager-load
May 7, 2018
Merged

Fix eager loading of relations when using parse/format#1838
ricardograca merged 3 commits into
masterfrom
rg-eager-load

Conversation

@ricardograca

@ricardograca ricardograca commented May 7, 2018

Copy link
Copy Markdown
Member

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.

- Eager loading related models is failing when the parent model has a
custom id attribute and a parse/format method that mutates it.
- 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 merged commit 13ee6f5 into master May 7, 2018
@ricardograca
ricardograca deleted the rg-eager-load branch May 7, 2018 15:05
@skout90

skout90 commented Jun 23, 2018

Copy link
Copy Markdown

@ricardograca thanks!!!!!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Relations broken when using format/parse

2 participants