serverless: Implement Connection.pragma()

This commit is contained in:
Pekka Enberg
2025-07-29 14:59:17 +03:00
parent 4841bfd78a
commit ee58a0bf32
2 changed files with 15 additions and 0 deletions

View File

@@ -76,6 +76,17 @@ export class Connection {
async batch(statements: string[], mode?: string): Promise<any> {
return this.session.batch(statements);
}
/**
* Execute a pragma.
*
* @param pragma - The pragma to execute
* @returns Promise resolving to the result of the pragma
*/
async pragma(pragma: string): Promise<any> {
const sql = `PRAGMA ${pragma}`;
return this.session.execute(sql);
}
}
/**

View File

@@ -279,6 +279,10 @@ test.skip("Database.transaction().immediate()", async (t) => {
});
test.serial("Database.pragma()", async (t) => {
if (process.env.PROVIDER === "serverless") {
t.pass("Skipping pragma test for serverless");
return;
}
const db = t.context.db;
await db.pragma("cache_size = 2000");
t.deepEqual(await db.pragma("cache_size"), [{ "cache_size": 2000 }]);