-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
The current PDOStatement implementation has two issues with object fetching:
- In the fetch() method, while there is a case for PDO::FETCH_OBJ that converts the row to an object using (object) $row, the method's return type is incorrectly typed as array instead of mixed.
- In the fetchAll() method, the PDO::FETCH_OBJ case is incorrectly implemented. It's currently returning the raw $allRows array without converting each row to an object:
return match ($mode) {
PDO::FETCH_BOTH => array_merge($allRows, $rowValues),
PDO::FETCH_ASSOC, PDO::FETCH_NAMED => $allRows,
PDO::FETCH_NUM => $rowValues,
PDO::FETCH_OBJ => $allRows, // <-- This is wrong
default => throw new \PDOException('Unsupported fetch mode.'),
};Expected Behavior
- The fetch() method should have a return type of mixed to properly reflect that it can return objects.
- The fetchAll() method should convert each row to an object when PDO::FETCH_OBJ is specified.
Impact
This bug affects any Laravel applications using the libsql driver that expect to receive objects from database queries, which is the default behavior in Laravel. Currently, it requires workarounds like manually casting results to objects or using Laravel's collection methods to handle the conversion.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels