From e25f2f594a23a348cd1e9e86d79b3ec264cd322d Mon Sep 17 00:00:00 2001 From: Emily Stark Date: Wed, 5 Jun 2013 23:46:14 -0700 Subject: [PATCH] Fix a couple failing mongo-livedata tests. Transform was being applied to every single Mongo query, including those issued from _pollMongo. This led to the transformed doc being sent over DDP, and then the client applied the transformation again. Instead, pass the useTransform flag to prevent _pollMongo from transforming, so that the whole doc gets sent over DDP and then the client does the transform, which is (I think?) what is supposed to happen. I also think but am not sure that transform is supposed to be applied for SynchronousCursors created for tailable cursors, so I had those SynchronousCursors have useTransform=true. --- packages/mongo-livedata/mongo_driver.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/mongo-livedata/mongo_driver.js b/packages/mongo-livedata/mongo_driver.js index b283a46073..dc653eefa4 100644 --- a/packages/mongo-livedata/mongo_driver.js +++ b/packages/mongo-livedata/mongo_driver.js @@ -446,19 +446,14 @@ _Mongo.prototype._createSynchronousCursor = function (cursorDescription, replaceTypes(cursorDescription.selector, replaceMeteorAtomWithMongo), options.fields, mongoOptions); - return new SynchronousCursor(dbCursor, cursorDescription); + return new SynchronousCursor(dbCursor, cursorDescription, useTransform); }; -var SynchronousCursor = function (dbCursor, cursorDescription) { +var SynchronousCursor = function (dbCursor, cursorDescription, useTransform) { var self = this; self._dbCursor = dbCursor; self._cursorDescription = cursorDescription; - - if (cursorDescription.options.transform) - self._transform = Deps._makeNonreactive( - cursorDescription.options.transform); - else - self._transform = null; + self._transform = useTransform && cursorDescription.options.transform; // Need to specify that the callback is the first argument to nextObject, // since otherwise when we try to call it with no args the driver will @@ -928,7 +923,8 @@ _Mongo.prototype._observeChangesTailable = function ( + " tailable cursor without a " + (ordered ? "addedBefore" : "added") + " callback"); } - var cursor = self._createSynchronousCursor(cursorDescription); + var cursor = self._createSynchronousCursor(cursorDescription, + true /* useTransform */); var stopped = false; var lastTS = undefined; @@ -970,7 +966,7 @@ _Mongo.prototype._observeChangesTailable = function ( cursor = self._createSynchronousCursor(new CursorDescription( cursorDescription.collectionName, newSelector, - cursorDescription.options)); + cursorDescription.options), true /* useTransform */); } } });