-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 4.2.8, 6.0.12
-
Component/s: None
-
Query Execution
-
ALL
version:6.0.12 4.2.8
db.t1.insert({id:1})
db.t1.insert({id:2})
db.t1.insert({})
db.t1.insert({id:2})
db.t1.find()
{ “_id” : ObjectId(“65a62118842d8bddd7ef9699”), “id” : 1 } { “_id” : ObjectId(“65a62119842d8bddd7ef969a”), “id” : 2 } { “_id” : ObjectId(“65a6211c842d8bddd7ef969b”) } { “_id” : ObjectId(“65a6211f842d8bddd7ef969c”), “id” : 2 }
— There are no nulls in the result set
db.t1.distinct(‘id’)
[ 1, 2 ]
– After creating the index, there are nulls in the result set
db.t1.createIndex(\{id:1}) { “numIndexesBefore” : 1, “numIndexesAfter” : 2, “createdCollectionAutomatically” : false, “ok” : 1 }
db.t1.distinct(‘id’)
[ null, 1, 2 ]
After adding the index, null values appeared in the result set, causing the application processing logic to change. I would like to ask if this is a bug.
- duplicates
-
SERVER-14832 Distinct command result set may include or exclude null/undefined depending on presence of index
- Needs Scheduling