Invalid SQL Generated when using Relation Manager

Hi folks, I was interested to explore this. I issued this command

MyPropertyResource my_property_rooms room_name


and then registered the relation. When I execute the app I am getting this SQL being generated:

SELECT
  count(*) AS aggregate
FROM
  `my_property_rooms`
WHERE
  `my_property_rooms`.`my_property_my_property_id` = 6
  AND `my_property_rooms`.`my_property_my_property_id` IS NOT NULL

It should read like this

SELECT
  count(*) AS aggregate
FROM
  `my_property_rooms`
WHERE
  `my_property_rooms`.`my_property_id` = 6
  AND `my_property_rooms`.`my_property_id` IS NOT NULL


I cannot see where it's looking when generating the SQL that could result in it determining that there is a column called
my_property_my_property_id


Anyone able to help?

thx
J
Solution
It's probably or in the other order:

public function my_property_rooms()
{
  return $this->hasMany(MyPropertyRoom::class, 'property_room_id', 'my_property_id');
}
Was this page helpful?