Fix error trying to generate report for many items

When adding many search conditions (e.g., when matching many items with the
`key` condition), the query can fail due to either the bound parameter limit or
the expression tree size limit.

To avoid this, add support for an 'inlineFilter' property on search conditions
when using the 'is' or 'isNot' operator. 'inlineFilter' is a function that
returns a quoted value suitable for direct embedding in the SQL statement, or
false if not valid. Multiple consecutive conditions for the same 'inlineFilter'
field are combined into an `IN (x, y, z)` condition.
This commit is contained in:
Dan Stillman 2017-01-21 03:38:36 -05:00
parent dcd1da70af
commit 9b247ebba7
4 changed files with 99 additions and 39 deletions

View file

@ -224,6 +224,17 @@ describe("Zotero.Search", function() {
});
});
describe("key", function () {
it("should allow more than max bound parameters", function* () {
let s = new Zotero.Search();
let max = Zotero.DB.MAX_BOUND_PARAMETERS + 100;
for (let i = 0; i < max; i++) {
s.addCondition('key', 'is', Zotero.DataObjectUtilities.generateKey());
}
yield s.search();
});
});
describe("savedSearch", function () {
it("should return items in the saved search", function* () {
var search = yield createDataObject('search');