hyperstack-org / hyperstack-org/hyperstack
assignment to has_many through relationship does not work
- Dominant language
- JavaScript
- Stars
- 538
- Forks
- 41
- PR merge metrics
- No merged PRs in 30d
Description
For example `physician.patients = [patient1, patient2, patient3]` does not work (assuming `patients` is a `has_many :through` relationship through an appointments table.
The problem is that updating patients, implies removal of any existing records in the appointments table, *and* creation of new appointments. In fact we have to investigate what rails does if for example some appointments for a patient already exist.
At any rate it involves several operations take place.
A simplistic approach be to loop through and delete any existing records, THEN to loop through pushing the new records on.
This might be sufficient for a work around, with perhaps a warning.
A better approach might be to have a separate operation, that makes a single call to the server, the update the relationship. This has the advantage of insuring it follows rails semantics.
A third approach would be to just disallow this method, with an error message.
Input needed!
Contributor guide
Research direction
The issue names no files, tests, or entry points. Start by reproducing physician.patients = [patient1, patient2, patient3] with a has_many :through relationship through an appointments table, then establish expected behavior for existing appointments and whether assignment should update, reject, or remain unsupported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rails, ruby
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 15/100