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

FilesCollection.findOne(null) should return null #210

Closed
exKAZUu opened this issue Aug 30, 2016 · 4 comments
Closed

FilesCollection.findOne(null) should return null #210

exKAZUu opened this issue Aug 30, 2016 · 4 comments

Comments

@exKAZUu
Copy link
Contributor

exKAZUu commented Aug 30, 2016

Although Mongo.Collection.findOne(null) always returns null, FilesCollection.findOne(null) returns a document.
I feel it's confusing, so I would propose that FilesCollection.findOne(null) should return null.

@dr-dimitru dr-dimitru added this to the v.Next milestone Aug 30, 2016
@dr-dimitru
Copy link
Member

Agree, will add to next release
Currently it acts as FilesCollection.findOne({})

@dr-dimitru dr-dimitru added the bug label Aug 30, 2016
dr-dimitru added a commit that referenced this issue Sep 5, 2016
dr-dimitru added a commit that referenced this issue Sep 5, 2016
 - Fix #214 - Chunks was incorrectly generated, without padding - Fixed
 - Fix #212 - Set token cookie after user logged-in
 - Fix #210 - Now `FilesCollection#findOne()` has same behaviour, as
`MongoCollection#findOne()`
 - `protected` hook optimisation
@dr-dimitru dr-dimitru mentioned this issue Sep 5, 2016
dr-dimitru added a commit that referenced this issue Sep 5, 2016
v1.7.3
 - Fix #214 - Chunks was incorrectly generated, without padding - Fixed
 - Fix #212 - Set token cookie after user logged-in
 - Fix #210 - Now `FilesCollection#findOne()` has same behaviour, as `MongoCollection#findOne()`
 - `protected` hook optimisation
@dr-dimitru
Copy link
Member

Hi @exKAZUu ,

This issue is solved in v1.7.3
Please update and test it on your end.

@exKAZUu
Copy link
Contributor Author

exKAZUu commented Sep 6, 2016

Hi, thank you for your update!
I checked the new version and found some issues.
(Sorry. I should have mentioned about find.)

Here is the behaviour of Mongo.Collection (i.e. expected).

Collection.find({}).fetch() => an array of documents
Collection.find().fetch() => an array of documents
Collection.find(null).fetch() => an empty array
Collection.find(undefined).fetch() => an empty array

Collection.findOne({}) => a documents
Collection.findOne() => a documents
Collection.findOne(null) => undefined
Collection.findOne(undefined) => undefined

However, FilesCollection now works as follows.

Collection.find({}).fetch() => an array of documents
Collection.find().fetch() => an array of documents
Collection.find(null).fetch() => an array of documents (should be an empty array)
Collection.find(undefined).fetch() => an array of documents (should be an empty array)

Collection.findOne({}) => a document
Collection.findOne() => undefined (should be a document)
Collection.findOne(null) => undefined
Collection.findOne(undefined) => undefined

@exKAZUu
Copy link
Contributor Author

exKAZUu commented Sep 6, 2016

I suspect that it is caused by the difference between JavaScript (ES2015) and CoffeeScript.
Although CoffeeScript's default values for arguments are used when the argument is null or undefined, JavaScript's default values for arguments are used when the argument is only undefined.

exKAZUu added a commit to exKAZUu/Meteor-Files that referenced this issue Sep 6, 2016
@exKAZUu exKAZUu mentioned this issue Sep 6, 2016
dr-dimitru added a commit that referenced this issue Sep 7, 2016
exKAZUu added a commit to exKAZUu/Meteor-Files that referenced this issue Sep 8, 2016
@exKAZUu exKAZUu mentioned this issue Sep 8, 2016
dr-dimitru added a commit that referenced this issue Oct 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants