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

Investigate issues with includes #16

Open
glacials opened this issue Oct 21, 2024 · 6 comments · May be fixed by #17
Open

Investigate issues with includes #16

glacials opened this issue Oct 21, 2024 · 6 comments · May be fixed by #17
Labels
bug Something isn't working

Comments

@glacials
Copy link
Owner

It seems this code is returning no record:

@race = Race.includes(entries: [:runner]).find(params[:id])

whereas this code is correctly returning a record:

@race = Race.find(params[:id])

Discovered while going through strict_loading audits in Rails 6.1.

@glacials glacials added the bug Something isn't working label Oct 21, 2024
@ianbayne
Copy link
Contributor

@glacials: I can take a look at this 👍 Regarding the above, is your setup something like the following?

class Race
  has_many :entries
end

class Entry
  belongs_to :race
  belongs_to :runner
end

class Runner
  has_many :entries
end

race = Race.create
runner = Runner.create
entry = Entry.create(race: race, runner: runner)

@glacials
Copy link
Owner Author

Yep, exactly! Thanks for volunteering to take a look at this.

@ianbayne
Copy link
Contributor

Sure thing! I should have included this above, but all three models mixing in FriendlyUUID? I.e.,

class Race
  include FriendlyUUID

  has_many :entries
end

class Entry
  include FriendlyUUID

  belongs_to :race
  belongs_to :runner
end

etc

@ianbayne ianbayne linked a pull request Nov 30, 2024 that will close this issue
@ianbayne
Copy link
Contributor

@glacials, I'm not able to reproduce the error you're seeing. Can you take a look at my WIP PR and let me know if there's something I'm missing about the setup required to do so? Thanks!

@ianbayne
Copy link
Contributor

Re-ping for @glacials in case you missed the above 🙇

@glacials
Copy link
Owner Author

Sorry for awol, have not had much free time. In my example actually only Race uses FriendlyUUID, the others use standard auto-incrementing integer IDs with no gems involved.

The link I provided above is the actual code base I encountered this in, if you're still having trouble with the test and interested enough to try to repro there. Thanks for all the effort, I really appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants