Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
deno-version: "v2.x"

- name: Check Formatting
run: deno fmt --check --ignore=sqlite
run: deno fmt --check

- name: Lint
run: deno lint --ignore=sqlite,bench
run: deno lint

- name: Check
run: deno check src/ test/ scripts/ mod.ts
Expand Down
1 change: 1 addition & 0 deletions bench/bench_bun.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import process from "node:process";
import { Database } from "bun:sqlite";

// Unsafe concurrency is default.
Expand Down
1 change: 1 addition & 0 deletions bench/bench_bun_ffi.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import process from "node:process";
import { dlopen, ptr } from "bun:ffi";

import {
Expand Down
2 changes: 1 addition & 1 deletion bench/bench_deno_wasm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DB } from "https://deno.land/x/sqlite/mod.ts";
import { DB } from "https://deno.land/x/sqlite@v3.9.1/mod.ts";
import { nextTick } from "https://deno.land/std@0.126.0/node/_next_tick.ts";

const db = new DB(":memory:");
Expand Down
1 change: 1 addition & 0 deletions bench/bench_node.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import process from "node:process";
const db = require("better-sqlite3")(":memory:");

db.exec("PRAGMA auto_vacuum = none");
Expand Down
2 changes: 1 addition & 1 deletion bench/northwind/deno_old.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Database } from "https://deno.land/x/sqlite3@0.4.3/mod.ts";
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
import { bench, run } from "../../node_modules/mitata/src/cli.mjs";

const db = new Database("./bench/northwind.sqlite");

Expand Down
2 changes: 1 addition & 1 deletion bench/northwind/node.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bench, run } from "mitata";
import { createRequire } from "module";
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);
const db = require("better-sqlite3")("./bench/northwind.sqlite");
Expand Down
11 changes: 5 additions & 6 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
"bench-bun:northwind": "bun run bench/northwind/bun.js"
},

"fmt": {
"exclude": [
"sqlite"
]
},

"lint": {
"exclude": ["bench"],
"rules": {
Expand All @@ -46,5 +40,10 @@
"explicit-module-boundary-types"
]
}
},
"compilerOptions": {
"types": [
"./node_modules/bun-types/index.d.ts"
]
}
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
"dependencies": {
"better-sqlite3": "^7.6.2",
"mitata": "^0.1.6"
},
"devDependencies": {
"bun-types": "^1.2.14"
}
}
28 changes: 23 additions & 5 deletions src/statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,13 @@ export class Statement<TStatement extends object = Record<string, any>> {
)(getColumn);
let status = sqlite3_step(handle);
while (status === SQLITE3_ROW) {
result.push(getRowArray(handle, this.int64 ?? this.db.int64, this.parseJson ?? this.db.parseJson));
result.push(
getRowArray(
handle,
this.int64 ?? this.db.int64,
this.parseJson ?? this.db.parseJson,
),
);
status = sqlite3_step(handle);
}
if (status !== SQLITE3_DONE) {
Expand Down Expand Up @@ -501,7 +507,13 @@ export class Statement<TStatement extends object = Record<string, any>> {
)(getColumn);
let status = sqlite3_step(handle);
while (status === SQLITE3_ROW) {
result.push(getRowArray(handle, this.int64 ?? this.db.int64, this.parseJson ?? this.db.parseJson));
result.push(
getRowArray(
handle,
this.int64 ?? this.db.int64,
this.parseJson ?? this.db.parseJson,
),
);
status = sqlite3_step(handle);
}
if (!this.#hasNoArgs && !this.#bound && params.length) {
Expand All @@ -514,9 +526,15 @@ export class Statement<TStatement extends object = Record<string, any>> {
return result as T[];
}

#rowObjectFn: ((h: Deno.PointerValue, int64: boolean, parseJson: boolean) => any) | undefined;
#rowObjectFn:
| ((h: Deno.PointerValue, int64: boolean, parseJson: boolean) => any)
| undefined;

getRowObject(): (h: Deno.PointerValue, int64: boolean, parseJson: boolean) => any {
getRowObject(): (
h: Deno.PointerValue,
int64: boolean,
parseJson: boolean,
) => any {
if (!this.#rowObjectFn || !this.#unsafeConcurrency) {
const columnNames = this.columnNames();
const getRowObject = new Function(
Expand Down Expand Up @@ -733,7 +751,7 @@ export class Statement<TStatement extends object = Record<string, any>> {

/** Iterate over resultant rows from query. */
*iter(...params: RestBindParameters): IterableIterator<any> {
this.#begin();
this.#begin();
this.#bindAll(params);
const getRowObject = this.getRowObject();
const int64 = this.int64 ?? this.db.int64;
Expand Down