dyedgreen / deno-sqlite

Deno SQLite module
https://deno.land/x/sqlite
MIT License
409 stars 36 forks source link

Wrong type for query method #166

Closed grenierdev closed 2 years ago

grenierdev commented 2 years ago

https://github.com/dyedgreen/deno-sqlite/blob/3b491b1ceda495f1bbc9069b2c44a5cbf2d80cec/src/db.ts#L107

Being <R extends Row = Row> and type Row = Array<unknown> basically means that I'm forced to use db.query<Something[]>(...) instead of db.query<Something>(...). The former has a return type of Something[][] instead of Something[].

dyedgreen commented 2 years ago

That's correct. SQLite queries always return zero or more rows with zero or more items each. So query should always return SomeTuple[].

E.g. this would return:

import { DB } from "https://deno.land/x/sqlite/mod.ts";
const db = new DB();
const result = db.query("SELECT 1, 2, 3");
console.log(result); // [ [ 1, 2, 3 ] ]