Skip to content

Commit 47059b2

Browse files
committed
We should only be limiting by the primaryKey when the object has one (has been persisted before).
1 parent 7e0c02a commit 47059b2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Temporal.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,11 @@ protected function endCurrent()
129129
*/
130130
private function getQuery()
131131
{
132-
$query = $this
133-
->where($this->primaryKey, '!=', $this->{$this->primaryKey})
134-
->where($this->temporalParentColumn, $this->{$this->temporalParentColumn});
132+
$query = $this->where($this->temporalParentColumn, $this->{$this->temporalParentColumn});
133+
134+
if ($this->{$this->primaryKey}) {
135+
$query->where($this->primaryKey, '!=', $this->{$this->primaryKey});
136+
}
135137

136138
if ($this->temporalPolymorphicTypeColumn) {
137139
$query->where($this->temporalPolymorphicTypeColumn, $this->{$this->temporalPolymorphicTypeColumn});

0 commit comments

Comments
 (0)