Skip to content

Commit

Permalink
send the current snapshot of the doc on query insert and don't assume…
Browse files Browse the repository at this point in the history
… a subscribed starting version
  • Loading branch information
nateps committed May 12, 2015
1 parent edc3e03 commit e7517c7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/server/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ Session.prototype._processQueryResults = function(collection, results, qopts) {
}

if (qopts.docMode) {
var atVersion = qopts.versions[collection] && qopts.versions[collection][docName];
var atVersion = qopts.versions && qopts.versions[collection] && qopts.versions[collection][docName];
// Only give the client snapshot data if the client requested it and they
// don't already have a copy of the document.
if (atVersion == null) {
Expand Down Expand Up @@ -622,14 +622,15 @@ Session.prototype._handleMessage = function(req, callback) {
self._send({a: 'q', id: qid, extra: extra});
};

// Note that only the docMode and not the full qopts is used, since
// qopts has the doc versions for the original subscription, and this
// emitter is sending an update from an ongoing subscription
var insertQueryOptions = {docMode: qopts.docMode};
emitter.onDiff = function(diff) {
for (var i = 0; i < diff.length; i++) {
var d = diff[i];
if (d.type === 'insert') {
// Note that qopts is not passed in here, since it has the doc
// versions for the original subscription, and this emitter is
// sending an update from and ongoing subscription
d.values = self._processQueryResults(req.c, d.values, {});
d.values = self._processQueryResults(req.c, d.values, insertQueryOptions);
}
}

Expand Down

0 comments on commit e7517c7

Please sign in to comment.