Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -851,15 +851,6 @@ public function pluck($column, $key = null)
{
$results = $this->get($key === null ? [$column] : [$column, $key]);

// Convert ObjectID's to strings
if (((string) $key) === '_id') {
$results = $results->map(function ($item) {
$item['_id'] = (string) $item['_id'];

return $item;
});
}

$p = Arr::pluck($results, $column, $key);

return new Collection($p);
Expand Down
11 changes: 11 additions & 0 deletions tests/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,17 @@ public function testPluck()
$this->assertEquals([25], $age);
}

public function testPluckObjectId()
{
$id = new ObjectId();
DB::table('users')->insert([
['id' => $id, 'name' => 'Jane Doe'],
]);

$names = DB::table('users')->pluck('name', 'id')->toArray();
$this->assertEquals([(string) $id => 'Jane Doe'], $names);
}

public function testList()
{
DB::table('items')->insert([
Expand Down
Loading