mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-07-25 13:23:44 +00: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:
commit
94e334a44a
3 changed files with 21 additions and 0 deletions
|
@ -214,6 +214,12 @@ test("Test Statement.database gets the database object", async t => {
|
||||||
t.is(stmt.database, db);
|
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 connect = async (path) => {
|
||||||
const db = new Database(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);
|
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 connect = async (path) => {
|
||||||
const db = new Database(path);
|
const db = new Database(path);
|
||||||
return [db];
|
return [db];
|
||||||
|
|
|
@ -178,10 +178,18 @@ class Statement {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get source() {
|
||||||
|
return this.stmt.source;
|
||||||
|
}
|
||||||
|
|
||||||
get reader() {
|
get reader() {
|
||||||
throw new Error("not implemented");
|
throw new Error("not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get source() {
|
||||||
|
return this.stmt.source;
|
||||||
|
}
|
||||||
|
|
||||||
get database() {
|
get database() {
|
||||||
return this.db;
|
return this.db;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue