Skip to content
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

Hierarchical relationships example swaps columns #3325

Merged
merged 1 commit into from Jun 7, 2020

Conversation

kaidadragonfly
Copy link
Contributor

I was having issues when testing the hierarchical relationship in a Phoenix app I was building.

It turns out doing Repo.preload(parent, :parent) would have the parent load the child, and having Repo.preload(child, :parent) would load nil. (Where parent has parent_id set to nil and child has parent_id set to parent's id.)

Swapping the columns like I did here makes things function correctly.

I was having issues when testing the hierarchical relationship in a Phoenix app I was building.  

It turns out doing `Repo.preload(parent, :parent)` would have the parent load the child, and having `Repo.preload(child, :parent)` would load `nil`.  (Where `parent` has `parent_id` set to `nil` and `child` has `parent_id` set to `parent`'s id.)

Swapping the columns like I did here makes things function correctly.
@josevalim josevalim merged commit b8c5c73 into elixir-ecto:master Jun 7, 2020
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@kaidadragonfly kaidadragonfly deleted the patch-1 branch June 7, 2020 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants