Skip to content

Commit 7f0851d

Browse files
authoredAug 25, 2017
Merge pull request #242 from elmdash/ps/primary-key-fix
Fix query builder: get primary key from model
2 parents b89312a + f648e15 commit 7f0851d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎src/QueryBuilder.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -721,12 +721,13 @@ protected function getDuplicatesQuery()
721721

722722
$waFirst = $this->query->getGrammar()->wrapTable($firstAlias);
723723
$waSecond = $this->query->getGrammar()->wrapTable($secondAlias);
724+
$pk = $this->model->getKeyName();
724725

725726
$query = $this->model
726727
->newNestedSetQuery($firstAlias)
727728
->toBase()
728729
->from($this->query->raw("{$table} as {$waFirst}, {$table} {$waSecond}"))
729-
->whereRaw("{$waFirst}.id < {$waSecond}.id")
730+
->whereRaw("{$waFirst}.{$pk} < {$waSecond}.{$pk}")
730731
->whereNested(function (BaseQueryBuilder $inner) use ($waFirst, $waSecond) {
731732
list($lft, $rgt) = $this->wrappedColumns();
732733

0 commit comments

Comments
 (0)
Failed to load comments.