Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Models/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,12 @@ private function buildAncestorsQuery(Builder $builder, $id, $withSelf)
return $builder
->join(
$this->closure->getTable(),
$this->closure->getAncestorColumn(),
$this->closure->getQualifiedAncestorColumn(),
'=',
$this->getQualifiedKeyName()
)
->where($this->closure->getDescendantColumn(), '=', $id)
->where($this->closure->getDepthColumn(), $depthOperator, 0);
->where($this->closure->getQualifiedDescendantColumn(), '=', $id)
->where($this->closure->getQualifiedDepthColumn(), $depthOperator, 0);
}

/**
Expand Down Expand Up @@ -563,12 +563,12 @@ private function buildDescendantsQuery(Builder $builder, $id, $withSelf)
return $builder
->join(
$this->closure->getTable(),
$this->closure->getDescendantColumn(),
$this->closure->getQualifiedDescendantColumn(),
'=',
$this->getQualifiedKeyName()
)
->where($this->closure->getAncestorColumn(), '=', $id)
->where($this->closure->getDepthColumn(), $depthOperator, 0);
->where($this->closure->getQualifiedAncestorColumn(), '=', $id)
->where($this->closure->getQualifiedDepthColumn(), $depthOperator, 0);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions tests/migrations/2014_01_18_162506_create_entities_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public function up()
$table->integer('position', false, true);
$table->softDeletes();

// Ensures there are no ambiguous column names in queries involving the closure table
$table->integer('ancestor')->nullable();
$table->integer('descendant')->nullable();
$table->integer('depth')->nullable();

$table->foreign('parent_id')->references('id')->on('entities')->onDelete('set null');

$table->engine = 'InnoDB';
Expand Down