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

should be able to delete target instances based on filters in HasManyThrough relation #5852

Closed
2 tasks
agnes512 opened this issue Jun 29, 2020 · 0 comments · Fixed by #5858
Closed
2 tasks
Assignees
Labels
bug Relations Model relations (has many, etc.)

Comments

@agnes512
Copy link
Contributor

Steps to reproduce

a Doctor has many Patients through Appointment, the relation called patients.

Doctor :           [{id: 1, dec: 'doctor'}]
Appointment:       [{doctorId: 1, patientId: 1}, {doctorId: 1, patientId: 2}]
Patient:           [{id: 1, name: 'p1'}, {id: 2, name: 'p2'}]

Current Behavior

// delete all patients that belongs to doctor id 1 where the patient name is p2
doctorRepo.patients(1).delete({name: 'p2'});

The target p2 gets deleted, but patient p1 is no longer traversable as the through model Appointment{doctorId: 1, patientId: 1} gets deleted too.

Expected Behavior

Should delete the related through models instead of deleting all throughs that belong to the same source key.

Acceptance Criteria

  • redesign the delete method in hasManyThrough repository
  • add tests to verify the new behaviour
@agnes512 agnes512 added bug Relations Model relations (has many, etc.) labels Jun 29, 2020
@agnes512 agnes512 self-assigned this Jun 29, 2020
@agnes512 agnes512 changed the title should able to delete target instances based on filters in HasManyThrough relation should be able to delete target instances based on filters in HasManyThrough relation Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Relations Model relations (has many, etc.)
Projects
None yet
1 participant