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

Fix exception when using a resource with a composite primary/foreign key association #3335

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

filipegiusti
Copy link
Contributor

Fixes #3334

Fix NoMethodError: undefined method to_sym' for an instance of Array` raised by this line when an association uses a composite primary key/foreign key.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Fix avo-hq#3334

Fix `NoMethodError: undefined method `to_sym' for an instance of Array` raised by this line when an association uses a composite primary key/foreign key.
Copy link

codeclimate bot commented Oct 11, 2024

Code Climate has analyzed commit a8cdcfa and detected 0 issues on this pull request.

View more on Code Climate.

@adrianthedev
Copy link
Collaborator

Thanks @filipegiusti!
Would you be able to add some tests for this as well?

The approach I would take is to create a new model & resource which uses composite foreign keys and test that.

Thank you for tackling this!

@filipegiusti
Copy link
Contributor Author

filipegiusti commented Oct 21, 2024

The approach I would take is to create a new model & resource which uses composite foreign keys and test that.

I searched for a test file at spec/lib/avo/fields/belongs_to_field.rb or using the search term spec fields belongs_to but I couldn't find anything. I'm not sure where such test would be and how it would look like, I don't have much experience testing libraries.

PS: I also searched for some sort of coverage tool that would help pinpoint which tests cover that method and tried to get github copilot to find such tests, all without luck.

@adrianthedev
Copy link
Collaborator

Can you create a new spec next to this one and test only the composite behavior?

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.

Exception is raised when association uses a composite primary/foreign key
2 participants