Skip to content

Commit 4d1a7fa

Browse files
committed
Fix normal query projection
1 parent 1826784 commit 4d1a7fa

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/Jenssegers/Mongodb/Query/Builder.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,18 +285,14 @@ 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-
}
293288
$options = [];
294289

295-
// Apply order, offset, limit and hint
290+
// Apply order, offset, limit and projection
296291
if ($this->timeout) $options['maxTimeMS'] = $this->timeout;
297292
if ($this->orders) $options['sort'] = $this->orders;
298293
if ($this->offset) $options['skip'] = $this->offset;
299294
if ($this->limit) $options['limit'] = $this->limit;
295+
if ($this->projections) $options['projection'] = $this->projections;
300296
// if ($this->hint) $cursor->hint($this->hint);
301297

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

0 commit comments

Comments
 (0)