Skip to content
New issue

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

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

Already on GitHub? # to your account

Fixing query with has_one #263

Merged
merged 5 commits into from
Feb 19, 2020
Merged

Fixing query with has_one #263

merged 5 commits into from
Feb 19, 2020

Conversation

jwoertink
Copy link
Member

@jwoertink jwoertink commented Oct 11, 2019

Fixes #223

This fixes 2 main issues with the has_one:

  • Using has_one when your model is namespaced
  • Doing a join query with has_one from both sides of the association

@jwoertink
Copy link
Member Author

@paulcsmith if you have a few min, I need to get back on this one. Maybe a second set of eyes would be great. Thanks!

@paulcsmith
Copy link
Member

@jwoertink Could you rebase and push? I'll try to take a look this evening! Thanks for the ping :D

@jwoertink jwoertink marked this pull request as ready for review February 19, 2020 00:51
@jwoertink jwoertink requested a review from paulcsmith February 19, 2020 00:51
@jwoertink
Copy link
Member Author

Alright, this is a long time coming 😅 It took me a min to remember what all is going on here, but it's all looking good now.

@@ -11,7 +11,7 @@ module Avram::Associations::HasOne
{% end %}

{% unless foreign_key %}
{% foreign_key = "#{@type.name.underscore}_id".id %}
{% foreign_key = "#{@type.name.underscore.split("::").last.id}_id".id %}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was fixed under the has_many a long time ago, so this now fixes it for the has_one

Copy link
Member

@paulcsmith paulcsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks perfect!

@paulcsmith
Copy link
Member

It still says WIP so holding off on merging just in case you wanted to do something else. Feel free to merge when you’re ready

@jwoertink jwoertink changed the title WIP: Fixing query with has_one Fixing query with has_one Feb 19, 2020
@jwoertink
Copy link
Member Author

oh, oops! Ok. I'll take one last look over it, but I'm pretty sure it's ready to go

@jwoertink jwoertink merged commit 2115117 into master Feb 19, 2020
@jwoertink jwoertink deleted the bugs/223 branch February 19, 2020 01:39
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issues with has_one association
2 participants