Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Treat Buffers as Arrays when rewriting MongoDB atoms.

mongodb 1.4.0-rc9 has a `binId` field of type Buffer on ObjectIDs, which
caused Meteor to crash when retrieving a document that was made up of
just an EJSON user-defined type. (Which should not necessarily be
supported, but `replaceNames` should probably treat Buffers as Arrays
regardless.)

Fixes #2095.
  • Loading branch information...
commit 63b3119127201a64eedaa1472230199d0ade9298 1 parent 5605050
@estark37 estark37 authored
View
5 packages/mongo-livedata/mongo_driver.js
@@ -17,7 +17,10 @@ MongoTest = {};
var replaceNames = function (filter, thing) {
if (typeof thing === "object") {
- if (_.isArray(thing)) {
+ // XXX This condition should match our `looksLikeArray` condition in
+ // underscore. (A Buffer might not be the only thing that should be
+ // treated as an array.)
+ if (_.isArray(thing) || thing instanceof Buffer) {
return _.map(thing, _.bind(replaceNames, null, filter));
}
var ret = {};
View
9 packages/mongo-livedata/mongo_livedata_tests.js
@@ -2954,3 +2954,12 @@ testAsyncMulti("mongo-livedata - undefined find options", [
test.equal(result, self.doc);
}
]);
+
+// We're not sure if this should be supported, but it was broken in
+// 0.8.1 and we decided to make a quick
+// fix. https://github.com/meteor/meteor/issues/2095
+Meteor.isServer && Tinytest.add("mongo-livedata - insert and retrieve EJSON user-defined type as document", function (test) {
+ var coll = new Meteor.Collection(Random.id());
+ coll.insert(new Meteor.Collection.ObjectID());
+ console.log(coll.find({}).fetch());
+});
Please sign in to comment.
Something went wrong with that request. Please try again.