DenoDDeno
Powered by
adoublefA
Denoβ€’3y agoβ€’
2 replies
adoublef

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

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();
});
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
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
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,944Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

multiple connections to local kv with sqlite from different thread
μ£½μ§€μ•Šμ„μ§€μ–΄λ‹€μ£½μ£½μ§€μ•Šμ„μ§€μ–΄λ‹€ / help
8mo ago
drizzle orm for deno and sqlite?
smailSsmail / help
3y ago
Deno Fresh + @db/sqlite
RRR / help
2mo ago
Different behaviour between Node and Deno with npm package
zingZzing / help
14mo ago