My implementation fails in the following scenario:
We have areas who have buildings who have floors who have rooms
All primary keys are called "id" are strings and all foreign_keys are called "whatever_id", where "whatever" is the object referenced, are theirfore also strings.
We now have the class:
class Areas extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;
public $incrementing = false;
public $timestamps = false;
protected $table = 'areas';
protected $keyType = 'string';
public function rooms()
{
return $this->hasManyDeep(Room::class, [Building::class, Floor::class]);
}
When accessed this generates the following query:
select * from "areas"."room" inner join "areas"."floor" on "areas"."floor"."id" = "areas"."room"."floor_id" inner join "areas"."building" on "areas"."building"."id" = "areas"."floor"."building_id" where "areas"."building"."area_id" = ? and "id"::text ILIKE ?
Postgres returns in this scenario a Ambiguous column error, since "id" is not well specified. If id is prefixed by "room", the code works as expected.
My implementation fails in the following scenario:
We have
areas
who havebuildings
who havefloors
who haverooms
All primary keys are called "id" are strings and all foreign_keys are called "whatever_id", where "whatever" is the object referenced, are theirfore also strings.We now have the class:
When accessed this generates the following query:
select * from "areas"."room" inner join "areas"."floor" on "areas"."floor"."id" = "areas"."room"."floor_id" inner join "areas"."building" on "areas"."building"."id" = "areas"."floor"."building_id" where "areas"."building"."area_id" = ? and "id"::text ILIKE ?
Postgres returns in this scenario a Ambiguous column error, since "id" is not well specified. If id is prefixed by "room", the code works as expected.