Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Fix null values with MongoDB distinct #285

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

foxbit19
Copy link

@foxbit19 foxbit19 commented Apr 9, 2015

During the use of MongoDB driver, the distinct operation doesn't return the expected string key for the array of results. This kind of behaviour, is exclusively relative to MongoDB because the $property doesn't exists, but there is a numeric key for the array instead.
The fix I propose, introduces a nullable check for $model[$property] and $model->$property and, if this check verifies the nullability, returns the first element of the array of results (in MongoDB the distinct operation works only on 1 field).

During the use of MongoDB driver, the *distinct* operation doesn't return the expected string key for the array of results. This kind of behaviour, is exclusively relative to MongoDB because the `$property` doesn't exists, but there is a numeric key for the array instead.
The fix I propose, introduces a nullable check for `$model[$property]` and `$model->$property` and, if this check verifies the nullability, returns the first element of the array of results (*in MongoDB the distinct operation works only on 1 field*).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant