Terminate cursor cleanly when using limit and index

Add db adapter support for clean cursor termination when passing
options.index and options.limit together. Previously this would cause a
crash because options.conditions was undefined.

// FREEBIE
This commit is contained in:
lilia 2015-11-10 16:00:26 -08:00
parent 987c067355
commit abf402b8c5
2 changed files with 20 additions and 4 deletions

View File

@ -476,8 +476,16 @@
// Cursor is not over yet.
if (options.limit && processed >= options.limit) {
// Yet, we have processed enough elements. So, let's just skip.
if (bounds && options.conditions[index.keyPath]) {
cursor.continue(options.conditions[index.keyPath][1] + 1); /* We need to 'terminate' the cursor cleany, by moving to the end */
if (bounds) {
if (options.conditions && options.conditions[index.keyPath]) {
cursor.continue(options.conditions[index.keyPath][1] + 1); /* We need to 'terminate' the cursor cleany, by moving to the end */
} else if (options.index && (options.index.upper || options.index.lower)) {
if (typeof options.index.order === 'string' && options.index.order.toLowerCase() === 'desc') {
cursor.continue(options.index.lower);
} else {
cursor.continue(options.index.upper);
}
}
} else {
cursor.continue(); /* We need to 'terminate' the cursor cleany, by moving to the end */
}

View File

@ -21834,8 +21834,16 @@ return jQuery;
// Cursor is not over yet.
if (options.limit && processed >= options.limit) {
// Yet, we have processed enough elements. So, let's just skip.
if (bounds && options.conditions[index.keyPath]) {
cursor.continue(options.conditions[index.keyPath][1] + 1); /* We need to 'terminate' the cursor cleany, by moving to the end */
if (bounds) {
if (options.conditions && options.conditions[index.keyPath]) {
cursor.continue(options.conditions[index.keyPath][1] + 1); /* We need to 'terminate' the cursor cleany, by moving to the end */
} else if (options.index && (options.index.upper || options.index.lower)) {
if (typeof options.index.order === 'string' && options.index.order.toLowerCase() === 'desc') {
cursor.continue(options.index.lower);
} else {
cursor.continue(options.index.upper);
}
}
} else {
cursor.continue(); /* We need to 'terminate' the cursor cleany, by moving to the end */
}