Skip to content

Commit c3beaf6

Browse files
committed
Fix set_authorizer() callback arguments.
1 parent b782c68 commit c3beaf6

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/sqlite-api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,8 @@ export function Factory(Module) {
630630
};
631631
function adapt(f) {
632632
return f instanceof AsyncFunction ?
633-
(async (_, iAction, p3, p4, p5, p6) => f(cvtArgs(_, iAction, p3, p4, p5, p6))) :
634-
((_, iAction, p3, p4, p5, p6) => f(cvtArgs(_, iAction, p3, p4, p5, p6)));
633+
(async (_, iAction, p3, p4, p5, p6) => f(...cvtArgs(_, iAction, p3, p4, p5, p6))) :
634+
((_, iAction, p3, p4, p5, p6) => f(...cvtArgs(_, iAction, p3, p4, p5, p6)));
635635
}
636636

637637
const result = Module.set_authorizer(db, adapt(xAuth), pApp);

test/callbacks.test.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,19 @@ for (const [key, factory] of FACTORIES) {
338338
rc = await sqlite3.exec(db, 'CREATE TABLE t(x)');
339339
expect(rc).toEqual(SQLite.SQLITE_OK);
340340

341-
expect(authorizations.length).toBeGreaterThan(0);
341+
let authCreateTable = false;
342+
for (const authorization of authorizations) {
343+
switch (authorization[0]) {
344+
case SQLite.SQLITE_CREATE_TABLE:
345+
authCreateTable = true;
346+
expect(authorization[1]).toEqual('t');
347+
expect(authorization[2]).toEqual('');
348+
expect(authorization[3]).toEqual('main');
349+
expect(authorization[4]).toEqual('');
350+
break;
351+
}
352+
}
353+
expect(authCreateTable).toBeTrue();
342354
});
343355

344356
it('should deny authorization', async function() {

0 commit comments

Comments
 (0)