Skip to content

Commit

Permalink
Merge pull request #212 from rhashimoto/fix-set-authorizer
Browse files Browse the repository at this point in the history
Fix set_authorizer() callback arguments.
  • Loading branch information
rhashimoto authored Sep 19, 2024
2 parents b782c68 + 60d42e8 commit 6a29e15
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wa-sqlite",
"version": "1.0.1",
"version": "1.0.2",
"type": "module",
"main": "src/sqlite-api.js",
"types": "src/types/index.d.ts",
Expand Down
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 6a29e15

Please sign in to comment.