Skip to content

Commit

Permalink
Fix set_authorizer() callback arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
shoestringresearch committed Sep 19, 2024
1 parent b782c68 commit c3beaf6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/sqlite-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,8 @@ export function Factory(Module) {
};
function adapt(f) {
return f instanceof AsyncFunction ?
(async (_, iAction, p3, p4, p5, p6) => f(cvtArgs(_, iAction, p3, p4, p5, p6))) :
((_, iAction, p3, p4, p5, p6) => f(cvtArgs(_, iAction, p3, p4, p5, p6)));
(async (_, iAction, p3, p4, p5, p6) => f(...cvtArgs(_, iAction, p3, p4, p5, p6))) :
((_, iAction, p3, p4, p5, p6) => f(...cvtArgs(_, iAction, p3, p4, p5, p6)));
}

const result = Module.set_authorizer(db, adapt(xAuth), pApp);
Expand Down
14 changes: 13 additions & 1 deletion test/callbacks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,19 @@ for (const [key, factory] of FACTORIES) {
rc = await sqlite3.exec(db, 'CREATE TABLE t(x)');
expect(rc).toEqual(SQLite.SQLITE_OK);

expect(authorizations.length).toBeGreaterThan(0);
let authCreateTable = false;
for (const authorization of authorizations) {
switch (authorization[0]) {
case SQLite.SQLITE_CREATE_TABLE:
authCreateTable = true;
expect(authorization[1]).toEqual('t');
expect(authorization[2]).toEqual('');
expect(authorization[3]).toEqual('main');
expect(authorization[4]).toEqual('');
break;
}
}
expect(authCreateTable).toBeTrue();
});

it('should deny authorization', async function() {
Expand Down

0 comments on commit c3beaf6

Please sign in to comment.