Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoreMongooseArray.includes not working correctly since version 5.6.0 #8203

Closed
hellivan opened this issue Sep 27, 2019 · 0 comments
Closed

CoreMongooseArray.includes not working correctly since version 5.6.0 #8203

hellivan opened this issue Sep 27, 2019 · 0 comments
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Milestone

Comments

@hellivan
Copy link

hellivan commented Sep 27, 2019

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.

@hellivan hellivan changed the title CoreMongooseArray.includes not working since version 5.6.0 CoreMongooseArray.includes not working correctly since version 5.6.0 Sep 27, 2019
@vkarpov15 vkarpov15 added this to the 5.7.3 milestone Sep 29, 2019
@vkarpov15 vkarpov15 added the confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. label Sep 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Projects
None yet
Development

No branches or pull requests

2 participants