fix(node/sqlite): sqlite named parameters (#28154)

This PR introduces support for named parameters in SQLite queries, as
outlined in #28134
This commit is contained in:
Gowtham K 2025-02-18 22:03:39 +05:30 committed by GitHub
parent 6206343b54
commit 9b9eeabcc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 137 additions and 6 deletions

View file

@ -198,6 +198,25 @@ CREATE TABLE two(id int PRIMARY KEY) STRICT;`);
db.close();
});
Deno.test("[node/sqlite] query should handle mixed positional and named parameters", () => {
const db = new DatabaseSync(":memory:");
db.exec(`CREATE TABLE one(variable1 TEXT, variable2 INT, variable3 INT)`);
db.exec(
`INSERT INTO one (variable1, variable2, variable3) VALUES ("test", 1 , 2);`,
);
const query = "SELECT * FROM one WHERE variable1=:var1 AND variable2=:var2 ";
const result = db.prepare(query).all({ var1: "test", var2: 1 });
assertEquals(result, [{
__proto__: null,
variable1: "test",
variable2: 1,
variable3: 2,
}]);
db.close();
});
Deno.test("[node/sqlite] StatementSync#iterate", () => {
const db = new DatabaseSync(":memory:");
const stmt = db.prepare("SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3");