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

[5.7] Fix loadMissing() with duplicate relation names #27040

Merged
merged 1 commit into from Jan 3, 2019

Conversation

Projects
None yet
3 participants
@staudenmeir
Copy link
Contributor

staudenmeir commented Jan 3, 2019

loadMissing() doesn't work with duplicate relationship names:

$posts = Post::with('comments')->get();
$posts->loadMissing('comments.parent.parent');
                                     ^^^^^^

This is caused by the structure of the internal $path array:

// before
array:2 [
  "comments" => "comments"
  "parent" => "parent"
]

// now
array:3 [
  0 => array:1 [
    "comments" => "comments"
  ]
  1 => array:1 [
    "parent" => "parent"
  ]
  2 => array:1 [
    "parent" => "parent"
  ]
]

Fixes #27039.

@phh

This comment has been minimized.

Copy link

phh commented Jan 3, 2019

Can confirm that this fixes my issue in #27039

@taylorotwell taylorotwell merged commit cec4317 into laravel:5.7 Jan 3, 2019

2 checks passed

continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@staudenmeir staudenmeir deleted the staudenmeir:load-missing branch Jan 3, 2019

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