Skip to content

Commit 74ff944

Browse files
committed
test(driver-sql): load the second better-sqlite3 connection through createRequire
The package carries no @types/better-sqlite3, so a static import fails the package typecheck. Claude-Session: https://claude.ai/code/session_01Bvd69VPa6puiNzzPUroDBx Co-authored-by: Claude <noreply@anthropic.com>
1 parent c669d16 commit 74ff944

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎packages/drivers/driver-sql/src/sql-driver-json-backfill-depth-limit.test.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,22 @@
3434

3535
import { describe, it, expect, afterEach, vi } from 'vitest';
3636
import { mkdtempSync, rmSync } from 'node:fs';
37+
import { createRequire } from 'node:module';
3738
import { tmpdir } from 'node:os';
3839
import { join } from 'node:path';
39-
import Database from 'better-sqlite3';
4040
import { SqlDriver } from './sql-driver.js';
4141
import { recoverUnencodedJsonText } from './unencoded-json-text.js';
4242

43+
/**
44+
* A second, raw connection — another process on the same file. Loaded through
45+
* `createRequire` because the package carries no `@types/better-sqlite3`; the
46+
* two members used are typed here.
47+
*/
48+
const Database = createRequire(import.meta.url)('better-sqlite3') as new (file: string) => {
49+
prepare(sql: string): { run(...args: unknown[]): unknown };
50+
close(): void;
51+
};
52+
4353
const T = 'json_depth_19912';
4454
const FIELDS = { label: { type: 'text' }, val: { type: 'json' } };
4555
const SCHEMA = { name: T, fields: FIELDS };

0 commit comments

Comments
 (0)