Closed
Description
API Platform version(s) affected: 4.x
Description
While workign on Laravel based project I've faced problem with PUT method in standard mode. It fails to update fields which have indexes.
How to reproduce
Define any non-primary field as index. Make PUL query to replace the record. As a result only non-indexed fields will be updated. No exceptions or error messages triggered.
Possible Solution
Adter some investigations I've found possible bug in the implementation of ApiPlatform\Laravel\Eloquent\Metadata\ModelMetadata class.
Eaxactly isColumnPrimaryKey method:
foreach ($indexes as $index) {
if (\in_array($column, $index['columns'], true)) {
return true;
}
}
This metod returns true whenever field is listed in the $indexes. What to my mind is wrong. Possible solution:
foreach ($indexes as $index) {
if (\in_array($column, $index['columns'], true)) {
return $index['primary'];
}
}
Metadata
Metadata
Assignees
Labels
No labels