#denodrivers/sqlite and deno-sqlit behave different with multiple `?` args

1 messages · Page 1 of 1 (latest)

fervent zephyr
#

I wanted to understand why these return different results

Deno.test("DB()", (_) => {
    // deno-sqlite
    const db = new DB(":memory:");

    const stmt = db.prepareQuery("SELECT ?, ?");

    const rs = stmt.all(["one", "two"]);
    //    ^? [ [ "one", "two" ] ]

    stmt.finalize();

    db.close();
});

Deno.test("Database() ? arguments", (_) => {
    // denodrivers/sqlite
    const db = new Database(":memory:");

    const stmt = db.prepare("SELECT ?, ?");

    const rs = stmt.all("one", "two");
    //    ^? [ { "?": "two" } ]

    stmt.finalize();
    db.close();
});

Deno.test("Database() : arguments", (_) => {
    // denodrivers/sqlite
    const db = new Database(":memory:");

    const stmt = db.prepare("SELECT :one, :two");

    const rs = stmt.all({ one: "one", two: "two" });
    //    ^? [ { ":one": "one", ":two": "two" } ]
    console.log(rs);

    stmt.finalize();
    db.close();
});

If I replace the denodrivers prepare statement to use named args I get correctly two values so unsure which method is needed to be called to get both to behave consistently

fervent zephyr
#

From the above its clear that the ? is overidden and therefore only one of them get's returned.

I am not sure if this is something that could be tackled or if it's even necessary as it isn't exactly a meanigful statement