mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-19 09:34:18 +01:00
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:
@@ -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);
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -178,10 +178,18 @@ class Statement {
|
||||
return this;
|
||||
}
|
||||
|
||||
get source() {
|
||||
return this.stmt.source;
|
||||
}
|
||||
|
||||
get reader() {
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
get source() {
|
||||
return this.stmt.source;
|
||||
}
|
||||
|
||||
get database() {
|
||||
return this.db;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user