Skip to content

Commit 1a13661

Browse files
committed
refactor(database): clean up pkey resolution
1 parent 2d41404 commit 1a13661

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/database/src/Builder/ModelInspector.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,15 +412,15 @@ public function getPrimaryKeyProperty(): ?PropertyReflector
412412
return null;
413413
}
414414

415-
$idProperties = arr($this->reflector->getProperties())
416-
->filter(fn (PropertyReflector $property) => $property->getType()->getName() === PrimaryKey::class);
415+
$primaryKeys = arr($this->reflector->getProperties())
416+
->filter(fn (PropertyReflector $property) => $property->getType()->matches(PrimaryKey::class));
417417

418-
return match ($idProperties->count()) {
418+
return match ($primaryKeys->count()) {
419419
0 => null,
420-
1 => $idProperties->first(),
420+
1 => $primaryKeys->first(),
421421
default => throw ModelHadMultiplePrimaryColumns::found(
422422
model: $this->model,
423-
properties: $idProperties->map(fn (PropertyReflector $property) => $property->getName())->toArray(),
423+
properties: $primaryKeys->map(fn (PropertyReflector $property) => $property->getName())->toArray(),
424424
),
425425
};
426426
}

0 commit comments

Comments
 (0)