Datatable
Datatable copied to clipboard
Fix null values with MongoDB distinct
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).