Skip to content

Commit 573bbb0

Browse files
authored
Fix partial matches (#8047)
Support character escaping
1 parent 6a450a0 commit 573bbb0

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/plugins/persistence/couch/CouchObjectProvider.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -466,21 +466,27 @@ class CouchObjectProvider {
466466
let stringifiedKeys = JSON.stringify(keysToSearch);
467467
const url = `${this.url}/_design/${designDoc}/_view/${viewName}`;
468468
const requestBody = {};
469+
let requestBodyString;
470+
469471
if (objectIdField === undefined) {
470472
requestBody.include_docs = true;
471473
}
472474

475+
if (limit !== undefined) {
476+
requestBody.limit = limit;
477+
}
478+
473479
if (startKey !== undefined && endKey !== undefined) {
474480
/* spell-checker: disable */
475481
requestBody.startkey = startKey;
476482
requestBody.endkey = endKey;
483+
requestBodyString = JSON.stringify(requestBody);
484+
requestBodyString = requestBodyString.replace('$START_KEY', startKey);
485+
requestBodyString = requestBodyString.replace('$END_KEY', endKey);
477486
/* spell-checker: enable */
478487
} else {
479488
requestBody.keys = stringifiedKeys;
480-
}
481-
482-
if (limit !== undefined) {
483-
requestBody.limit = limit;
489+
requestBodyString = JSON.stringify(requestBody);
484490
}
485491

486492
let objectModels = [];
@@ -490,7 +496,7 @@ class CouchObjectProvider {
490496
method: 'POST',
491497
headers: { 'Content-Type': 'application/json' },
492498
signal: abortSignal,
493-
body: JSON.stringify(requestBody)
499+
body: requestBodyString
494500
});
495501

496502
if (!response.ok) {

src/plugins/persistence/couch/CouchSearchProvider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class CouchSearchProvider {
9494
designDoc: 'object_names',
9595
viewName: 'object_names',
9696
startKey: preparedQuery,
97-
endKey: preparedQuery + '\\ufff0',
97+
endKey: preparedQuery + `\ufff0`,
9898
objectIdField: 'value',
9999
limit: 1000
100100
},

0 commit comments

Comments
 (0)