Fix crash when search uses no-op condition and includeParentsAndChildren
E.g., a nonexistent saved search
This commit is contained in:
parent
9e2ea008f4
commit
76081ab05f
2 changed files with 21 additions and 0 deletions
|
@ -1605,11 +1605,19 @@ Zotero.Search.prototype._buildQuery = Zotero.Promise.coroutine(function* () {
|
|||
}
|
||||
|
||||
if (includeParentsAndChildren || includeParents) {
|
||||
// Tweak forceNoResults expression to work with UNION
|
||||
if (condSQL == '0=1') {
|
||||
condSQL = 'SELECT 0=1';
|
||||
}
|
||||
condSQL += " UNION " + parentSQL;
|
||||
condSQLParams = condSQLParams.concat(parentSQLParams);
|
||||
}
|
||||
|
||||
if (includeParentsAndChildren || includeChildren) {
|
||||
// Tweak forceNoResults expression to work with UNION
|
||||
if (condSQL == '0=1') {
|
||||
condSQL = 'SELECT 0=1';
|
||||
}
|
||||
condSQL += " UNION " + childrenSQL;
|
||||
condSQLParams = condSQLParams.concat(childSQLParams);
|
||||
}
|
||||
|
|
|
@ -409,6 +409,19 @@ describe("Zotero.Search", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("includeParentsAndChildren", function () {
|
||||
it("should handle ANY search with no-op condition", async function () {
|
||||
var s = new Zotero.Search();
|
||||
s.libraryID = userLibraryID;
|
||||
s.name = "Test";
|
||||
s.addCondition('joinMode', 'any');
|
||||
s.addCondition('savedSearch', 'is', Zotero.Utilities.randomString());
|
||||
s.addCondition('includeParentsAndChildren', 'true');
|
||||
var matches = await s.search();
|
||||
assert.lengthOf(matches, 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("key", function () {
|
||||
it("should allow more than max bound parameters", function* () {
|
||||
let s = new Zotero.Search();
|
||||
|
|
Loading…
Reference in a new issue