Skip to content

Commit d51cddb

Browse files
authored
fix(laravel): index on non-primary key (#7183)
fixes #7182
1 parent 0a1a1ea commit d51cddb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Laravel/Eloquent/Metadata/ModelMetadata.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ public function getAttributes(Model $model): Collection
101101
}
102102

103103
/**
104-
* @param array<int, array{columns: string[]}> $indexes
104+
* @param array<int, array{columns: string[], primary?: bool}> $indexes
105105
*/
106106
private function isColumnPrimaryKey(array $indexes, string $column): bool
107107
{
108108
foreach ($indexes as $index) {
109-
if (\in_array($column, $index['columns'], true)) {
109+
if (\in_array($column, $index['columns'], true) && (true === ($index['primary'] ?? false))) {
110110
return true;
111111
}
112112
}

0 commit comments

Comments
 (0)