Merge 'bindings/javascript: Add source property to Statement' from Anton Harniakou

Let's you get the source string that was used to create the prepared
statement.

Reviewed-by: Diego Reis (@el-yawd)

Closes #1670
This commit is contained in:
Jussi Saurio
2025-06-09 08:24:47 +03:00
3 changed files with 21 additions and 0 deletions

View File

@@ -214,6 +214,12 @@ test("Test Statement.database gets the database object", async t => {
t.is(stmt.database, db);
});
test("Test Statement.source", async t => {
const [db] = await connect(":memory:");
let sql = "CREATE TABLE t (id int)";
let stmt = db.prepare(sql);
t.is(stmt.source, sql);
});
const connect = async (path) => {
const db = new Database(path);

View File

@@ -215,6 +215,13 @@ test("Test Statement.database gets the database object", async t => {
t.is(stmt.database, db);
});
test("Test Statement.source", async t => {
const [db] = await connect(":memory:");
let sql = "CREATE TABLE t (id int)";
let stmt = db.prepare(sql);
t.is(stmt.source, sql);
});
const connect = async (path) => {
const db = new Database(path);
return [db];