borogove

created pr with borogove/sqlite-injectable-driver.1 on 2026-11-09T19:46:34Z · by 3c31bc8c
commented on 2026-11-09T19:46:34Z · by 3c31bc8c
Changes are available at https://tangled.org/mrry.band/borogove on branch sqlite-injectable-driver.
added borogove/sqlite-injectable-driver.2 on 2026-11-09T20:05:07Z · by 3c31bc8c
1: 981fe7d = 1: 981fe7d Use arrays
2: ef9e639 = 2: ef9e639 Make prepare public, remove formatParam and first
3: f949361 ! 3: a97c836 Allow injectable drivers for Sqlite
commented on 2026-11-09T20:49:02Z · by 9e834e0d
browser tests dont pass
added borogove/sqlite-injectable-driver.3 on 2026-11-09T21:28:45Z · by 3c31bc8c
1: 981fe7d = 1: 981fe7d Use arrays
2: ef9e639 ! 2: 11eb826 Make prepare public, remove formatParam and first
3: a97c836 ! 3: 34cee7d Allow injectable drivers for Sqlite
cmds
checkout latest patchset:
ssh pr.pico.sh pull borogove:sqlite-injectable-driver | git am -3
checkout specific patchset revision:
ssh pr.pico.sh pull borogove:sqlite-injectable-driver [rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh borogove:sqlite-injectable-driver
add comment to patch request:
ssh pr.pico.sh comment borogove:sqlite-injectable-driver "lgtm!"

Patchset borogove/sqlite-injectable-driver.3 on 2026-11-09T21:28:45Z · commit 11eb826

Make prepare public, remove formatParam and first
Eric Roberts 2026-11-09T19:29:48Z
We were shifting off the first query because that's all the bind would
apply to, but then we were formatting the params there. We have a
general purpose prepare we can use, so we can delete formatParam and
stop treating the first query like a special case. This change did
necessitate updating test expecations. Haxe's bytes.ofdata mutates the
original arraybuffer to add two properties. Our tests then think they
don't equal each other even though they do in practice.

Makes prepare public so the injectable driver that I'm making for Tauri
can use it.
Semantic diff summary
0 added, 2 modified, 0 signature changed, 0 removed across 1 analyzed file (2 files skipped: unsupported file type)
+1 -2 borogove/persistence/Sqlite.hx #
......@@ -44,8 +44,7 @@ class Sqlite implements Persistence implements KeyValueStore {
4444 final media: MediaStore;
4545 final storeMessagesSerialized = new AsyncLock();
4646
47- @:allow(borogove)
48- private static function prepare(q: { sql: String, ?params: Array<Dynamic> }): String {
47+ public static function prepare(q: { sql: String, ?params: Array<Dynamic> }): String {
4948 return ~/\?/gm.map(q.sql, f -> {
5049 var p = (q.params ?? []).shift();
5150 return switch (Type.typeof(p)) {
+1 -13 borogove/persistence/SqliteDriver.js.hx #
......@@ -145,15 +145,13 @@ class SqliteDriver {
145145 }
146146
147147 private function execute(qs: Array<{ sql: String, ?params: Array<Dynamic> }>): Promise<Array<Dynamic>> {
148- final first = qs.shift();
149148 final sql = qs.map(q -> Sqlite.prepare(q) + ";");
150149 final items: Array<Dynamic> = [];
151150 var signalAllDone;
152151 final allDone = new Promise((resolve, reject) -> signalAllDone = resolve);
153152 return sqlite('exec', {
154153 dbId: dbId,
155- sql: [first.sql + ";"].concat(sql),
156- bind: (first.params ?? []).map(formatParam),
154+ sql: sql,
157155 rowMode: "object",
158156 callback: (r) -> {
159157 if (r.rowNumber == null) {
......@@ -177,15 +175,5 @@ class SqliteDriver {
177175 public function exec(sql: String, ?params: Array<Dynamic>) {
178176 return execMany([{ sql: sql, params: params }]);
179177 }
180-
181- private function formatParam(p: Dynamic): Dynamic {
182- return switch (Type.typeof(p)) {
183- case TClass(haxe.io.Bytes):
184- var bytes:Bytes = cast p;
185- return bytes.getData();
186- case _:
187- return p;
188- }
189- }
190178 }
191179 #end
+8 -3 test/persistence-tests.ts #
......@@ -1937,7 +1937,12 @@ export function sharedPersistenceTests(test) {
19371937 );
19381938 }
19391939 const loaded = await persistence.getOmemoPreKeys(identifier);
1940- expect(loaded).toEqual(preKeys);
1940+ expect(loaded).toHaveLength(preKeys.length);
1941+ const loadedById = new Map(loaded.map((key) => [key.keyId, key]));
1942+ for (const preKey of preKeys) {
1943+ const actual = loadedById.get(preKey.keyId);
1944+ expectKeyPair(actual.keyPair, preKey.keyPair);
1945+ }
19411946 });
19421947
19431948 test("storeOmemoSignedPreKey and getOmemoSignedPreKey", async ({
......@@ -2003,7 +2008,7 @@ export function sharedPersistenceTests(test) {
20032008 account,
20042009 address,
20052010 );
2006- expect(loaded).toEqual(identityKey);
2011+ expectKey(loaded, identityKey);
20072012 });
20082013
20092014 test("getOmemoSession returns null when none is stored", async ({
......@@ -2314,5 +2319,5 @@ function expectKeyPair(actual: TestKeyPair, expected: TestKeyPair) {
23142319 }
23152320
23162321 function expectKey(actual: ArrayBuffer, expected: ArrayBuffer) {
2317- expect(actual).toEqual(expected);
2322+ expect(new Uint8Array(actual)).toEqual(new Uint8Array(expected));
23182323 }
Back to top