Open
Description
Bug Report
Q | A |
---|---|
BC Break | yes |
Version | 5.0.1 |
Summary
When adding a filter, it goes always in first stage. If the query already have a match two stages will be created, making mongodb throw an exception.
Documentation states that $match stage that includes a $text must be the first stage in the pipeline.
Current behavior
The stage that comes from filters will always be the first in pipeline.
How to reproduce
- create a filter
final class ExcludeSoftDeletedFilter extends BsonFilter
{
public function addFilterCriteria(ClassMetadata $targetDocument): array
{
return [
'deletedAt' => null,
];
}
}
- run a query with texts:
$this->createAggregationBuilder()
->match()
->field('field')
->text('value')
An exception occured, transforming to an Error resource. {"exception":"[object] (MongoDB\\Driver\\Exception\\CommandException(code: 17313): $match with $text is only allowed as the first pipeline stage at /var/www/html/vendor/mongodb/mongodb/src/Operation/Aggregate.php:383
Expected behavior
In my opinion, the CriteriaMerger should be used when merging the attributes, or there should be a "reorder" before submitting the query, so the text stage should go first
Metadata
Metadata
Assignees
Labels
No labels