MedicOneSystems / MedicOneSystems/livewire-datatables
Multiple relationship with same table is showing wrong values
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.2k
- Forks
- 257
- PR merge metrics
- No merged PRs in 30d
Description
This fileds are fetching two different relationships
Column::name('assignedBy.first_name')->label('Assigned by')->alignCenter(),
Column::name('assignedTo.first_name')->label('Assigned to')->alignCenter(),
Both data is coming from same table (users)
public function assignedBy()
{
return $this->belongsTo(User::class);
}
public function assignedTo()
{
return $this->belongsTo(User::class);
}
Problem: The data-table is showing same value on both places
select `tasks`.`id` as `id`, `users`.`first_name` as `assignedBy.first_name`, `users`.`first_name` as `assignedTo.first_name` from `tasks` left join `users` on `tasks`.`assigned_by_id` = `users`.`id` where `tasks`.`deleted_at` is null order by `id` desc limit 10 offset 0
Note
#257 is more of an hack and not "a fix".
This issues is still there on the package. And it is clearly not an expected behaviour based on how the package configurations work.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two belongsTo relationships and inspect the generated SQL shown in the issue, especially how both users joins are selected and aliased. Compare the result with the expected assignedBy and assignedTo values, and consider issue #257 only as context because the report says it is not a complete fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- laravel, php
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100