Fixes #2097 - null !== undefined leads to overwriting client supplied _id on validated insert #2099

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

vsivsi commented May 1, 2014

Fixes #2097

null !== undefined leads to always overwriting client supplied _id with undefined for validated inserts, which led mongodb to create a new _id value for each such document.

@vsivsi vsivsi Fixes #2097 - null !== undefined lead to always overwriting client su…
…pplied _id with undefined for validated inserts, which led mongodb to create a new _id for each such document.
2c1caa6
@vsivsi vsivsi commented on the diff May 1, 2014
packages/mongo-livedata/collection.js
@@ -772,6 +772,11 @@ Meteor.Collection.prototype._validatedInsert = function (userId, doc,
generatedId) {
var self = this;
+ // This parameter is optional. Default value is null
vsivsi
vsivsi May 1, 2014

See line 703 above to see how generatedId can be undefined. When generatedId === null in the caller, it is not pushed to the argument list, leading to undefined here.

@vsivsi vsivsi changed the title from Fixes #2097 - null !== undefined lead to always overwriting client suppl... to Fixes #2097 - null !== undefined leads to overwriting client supplied _id on validated insert May 1, 2014
Owner
glasser commented May 1, 2014

Wow, sorry, I can't believe I didn't catch this (I swore I had tests that should catch this!)

I think the intended patch is actually to the code that invokes this.

@glasser glasser closed this in 5e0845a May 1, 2014
@glasser glasser added a commit that referenced this pull request May 1, 2014
@glasser glasser Follow-up to 4777e64: fix client-specified _id
This was a regression in 0.8.1 which caused client-specified `_id` to
always be ignored for collections with at least one allow/deny rule.

Fixes #2097. Fixes #2099.
1d40046
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment