add test + fix sqlite pb

This commit is contained in:
m
2026-09-10 22:08:27 +02:00
parent 4e2d92a80e
commit 6332e9cac4
4 changed files with 216 additions and 13 deletions
+14 -3
View File
@@ -1,4 +1,4 @@
import { getDatabase } from './client';
import { getDatabase, withDatabaseRetry } from './client';
import type { SQLiteBindValue } from 'expo-sqlite';
export type DbSession = {
@@ -14,5 +14,16 @@ export function __setDbForTests(db: DbSession | null): void {
}
export async function getSession(): Promise<DbSession> {
return override ?? (await getDatabase());
}
if (override) return override;
await getDatabase();
return liveSession;
}
const liveSession: DbSession = {
runAsync: (sql, ...params) =>
withDatabaseRetry((db) => db.runAsync(sql, ...params)),
getFirstAsync: (sql, ...params) =>
withDatabaseRetry((db) => db.getFirstAsync(sql, ...params)),
getAllAsync: (sql, ...params) =>
withDatabaseRetry((db) => db.getAllAsync(sql, ...params)),
};