-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Description
Do you want to request a feature or report a bug?
BUG
What is the current behavior?
CoreMongooseArray incorrectly/incompletely implements "includes" method since version 5.6.0.
If the current behavior is a bug, please provide the steps to reproduce.
https://gist.github.com/hellivan/0d3ce7722d6add10eab83bbfbca52cc5
What is the expected behavior?
Should print:
Array.includes: false
CoreMongooseArray.includes: false
"includes" should return false, since 'foo' is not included in friends array after index 1.
But instead following content is logged:
Array.includes: false
CoreMongooseArray.includes: true
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Mongoose: 5.6.0, 5.6.9, 5.7.2
Node: 8.16.0 12.3.1
The bug was possibly introduced by commit 97c4666 which introduced lib/types/core_array.js.
Since CoreMongooseArray extends Array type and Array.prototype.includes accepts a second parameter fromIndex according to the specs , implementation was incomplete from the beginning.