Skip to content

Commit 77aa041

Browse files
committed
feat: ignoreIncludeErrors flag
1 parent 5a9dbaa commit 77aa041

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

spec/rest.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,8 @@ describe('rest create', () => {
851851
})
852852
);
853853

854+
// when we try to include and unreadable child & ignore include errors
855+
// then the raw pointer is simply returned unhydrated.
854856
const response = await request({
855857
method: 'GET',
856858
url: `${baseUrl}&ignoreIncludeErrors=true`,

src/RestQuery.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,6 @@ function _UnsafeRestQuery(
113113
this.response = null;
114114
this.findOptions = {};
115115
this.context = context || {};
116-
const hasIgnoreIncludeErrors = Object.prototype.hasOwnProperty.call(
117-
restOptions,
118-
'ignoreIncludeErrors'
119-
);
120-
this.ignoreIncludeErrors = hasIgnoreIncludeErrors
121-
? !!restOptions.ignoreIncludeErrors
122-
: false;
123-
if (hasIgnoreIncludeErrors) {
124-
this.restOptions.ignoreIncludeErrors = this.ignoreIncludeErrors;
125-
if (this.ignoreIncludeErrors) {
126-
this.findOptions.ignoreIncludeErrors = true;
127-
}
128-
}
129116
if (!this.auth.isMaster) {
130117
if (this.className == '_Session') {
131118
if (!this.auth.user) {
@@ -218,6 +205,7 @@ function _UnsafeRestQuery(
218205
case 'includeAll':
219206
this.includeAll = true;
220207
break;
208+
// Propagate these options from restOptions to findOptions too
221209
case 'explain':
222210
case 'hint':
223211
case 'distinct':
@@ -226,9 +214,8 @@ function _UnsafeRestQuery(
226214
case 'limit':
227215
case 'readPreference':
228216
case 'comment':
229-
this.findOptions[option] = restOptions[option];
230-
break;
231217
case 'ignoreIncludeErrors':
218+
this.findOptions[option] = restOptions[option];
232219
break;
233220
case 'order':
234221
var fields = restOptions.order.split(',');
@@ -756,9 +743,6 @@ _UnsafeRestQuery.prototype.runFind = async function (options = {}) {
756743
return Promise.resolve();
757744
}
758745
const findOptions = Object.assign({}, this.findOptions);
759-
if (this.ignoreIncludeErrors) {
760-
findOptions.ignoreIncludeErrors = true;
761-
}
762746
if (this.keys) {
763747
findOptions.keys = this.keys.map(key => {
764748
return key.split('.')[0];

0 commit comments

Comments
 (0)