+25
-1
lines changedFilter options
+25
-1
lines changed Original file line number Diff line number Diff line change
@@ -375,7 +375,10 @@ class CustomAggregate {
375
375
result = Local<Value>::New(isolate, agg->value);
376
376
}
377
377
378
-
JSValueToSQLiteResult(isolate, ctx, result);
378
+
if (!result.IsEmpty()) {
379
+
JSValueToSQLiteResult(isolate, ctx, result);
380
+
}
381
+
379
382
if (is_final) {
380
383
DestroyAggregateData(ctx);
381
384
}
Original file line number Diff line number Diff line change
@@ -309,6 +309,27 @@ describe('step', () => {
309
309
});
310
310
311
311
describe('result', () => {
312
+
test('throws if result throws an error', (t) => {
313
+
const db = new DatabaseSync(':memory:');
314
+
t.after(() => db.close());
315
+
db.exec('CREATE TABLE data (value INTEGER)');
316
+
db.exec('INSERT INTO data VALUES (1), (2), (3)');
317
+
db.aggregate('sum_int', {
318
+
start: 0,
319
+
step: (acc, value) => {
320
+
return acc + value;
321
+
},
322
+
result: () => {
323
+
throw new Error('result error');
324
+
},
325
+
});
326
+
t.assert.throws(() => {
327
+
db.prepare('SELECT sum_int(value) as result FROM data').get();
328
+
}, {
329
+
message: 'result error'
330
+
});
331
+
});
332
+
312
333
test('executes once when options.inverse is not present', (t) => {
313
334
const db = new DatabaseSync(':memory:');
314
335
t.after(() => db.close());
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4