HasMany relationship uses incorrect foreign key
Closed this issue · 2 comments
vimofthevine commented
In 1581314#L2R396, $model->fk()
is used instead of $this->fk()
to retrieve the foreign key to use for has-many relationships.
For example, for two models (model and related_model) with a has-many relationship, the following select query is generated when accessing the related model ($model->related_models
):
SELECT ... FROM `related_models` WHERE `related_model_id` = 1
When it should be:
SELECT ... FROM `related_models` WHERE `model_id` = 1
Deleted user commented
Now that I see the fix, I remember again that I wanted to bring up this issue for a long time... :) But I fixed it myself and then forgot about it... Sorry for that and thanks for fixing! :)