Skip to content

Commit 11d10c2

Browse files
committed
test(plugin-pinyin-search): seed the boot-reconcile history in batched bulkCreate calls
The fixture wrote its 2,500-row history with one awaited driver.create per row. Batched bulkCreate (500 rows, SQLite's compound-SELECT ceiling) cuts the seed to five statements. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T5digj2EfFsbXihqJEo1ix
1 parent 5874d25 commit 11d10c2

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

‎packages/plugins/plugin-pinyin-search/src/boot-reconcile.integration.test.ts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const SYSTEM = { isSystem: true } as const;
3737
const HISTORIC = '2026-01-01T00:00:00.000Z';
3838
const ROWS = 2_500;
3939
const PAGE = 1_000;
40+
/** SQLite's compound-SELECT ceiling: the most rows one `bulkCreate` can carry. */
41+
const INSERT_BATCH = 500;
4042

4143
const PROBE_OBJECT = {
4244
name: PROBE,
@@ -98,9 +100,19 @@ class FixturePlugin implements Plugin {
98100
};
99101
}
100102

101-
/** A write that bypasses every hook and the audit stamp: an import, a migration. */
103+
/**
104+
* A write that bypasses every hook and the audit stamp: an import, a migration.
105+
* Batched `bulkCreate`, not one awaited `create` per row (#25749): 2,500
106+
* single-row autocommit inserts timed these cases out under CI load. A batch
107+
* is one `… UNION ALL SELECT …` statement on SQLite, which refuses more than
108+
* 500 terms ("too many terms in compound SELECT"), hence the slices. The
109+
* driver keeps the given `created_at`/`updated_at`, so the history stays older
110+
* than any watermark.
111+
*/
102112
async directInsert(rows: Array<Record<string, unknown>>): Promise<void> {
103-
for (const row of rows) await this.driver.create(PROBE, row);
113+
for (let i = 0; i < rows.length; i += INSERT_BATCH) {
114+
await this.driver.bulkCreate(PROBE, rows.slice(i, i + INSERT_BATCH));
115+
}
104116
}
105117

106118
async row(id: string): Promise<Record<string, any> | null> {

0 commit comments

Comments
 (0)