Skip to content

Commit 8f70329

Browse files
committed
Fix select columns
Revert previous projections since select columns is using projection.
1 parent 4d1a7fa commit 8f70329

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Jenssegers/Mongodb/Query/Builder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,19 @@ public function getFresh($columns = [])
285285
$columns[$column] = true;
286286
}
287287

288+
// Add custom projections.
289+
if ($this->projections)
290+
{
291+
$columns = array_merge($columns, $this->projections);
292+
}
288293
$options = [];
289294

290295
// Apply order, offset, limit and projection
291296
if ($this->timeout) $options['maxTimeMS'] = $this->timeout;
292297
if ($this->orders) $options['sort'] = $this->orders;
293298
if ($this->offset) $options['skip'] = $this->offset;
294299
if ($this->limit) $options['limit'] = $this->limit;
295-
if ($this->projections) $options['projection'] = $this->projections;
300+
if ($columns) $options['projection'] = $columns;
296301
// if ($this->hint) $cursor->hint($this->hint);
297302

298303
// Fix for legacy support, converts the results to arrays instead of objects.

0 commit comments

Comments
 (0)