refactor(session-query): share the header column bindings between both inserts
The baseline columns pushed the two INSERT binding lists past the clone threshold; one _headerBindings helper now owns the shared header prefix (the duplication gate's finding).
This commit is contained in:
@@ -526,6 +526,23 @@ export class SessionQuerySqlite extends SessionQueryService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The shared header column bindings both session tables lead with. */
|
||||||
|
private static _headerBindings(
|
||||||
|
header: SessionHeader,
|
||||||
|
): [string, number, number, string | null, string | null, number | null, number | null, string | null, string | null] {
|
||||||
|
return [
|
||||||
|
header.id,
|
||||||
|
header.version,
|
||||||
|
header.createdAt,
|
||||||
|
header.cwd ?? null,
|
||||||
|
header.parentSession ?? null,
|
||||||
|
header.seedLength ?? null,
|
||||||
|
header.delegationDepth ?? null,
|
||||||
|
header.sandboxMode ?? null,
|
||||||
|
header.approvalPolicy ?? null,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
private _replacePersistedSession(
|
private _replacePersistedSession(
|
||||||
entry: ObservedSession,
|
entry: ObservedSession,
|
||||||
revision: SessionPersistenceRevision,
|
revision: SessionPersistenceRevision,
|
||||||
@@ -537,19 +554,7 @@ export class SessionQuerySqlite extends SessionQueryService {
|
|||||||
INSERT INTO persisted_sessions
|
INSERT INTO persisted_sessions
|
||||||
(id, version, created_at, cwd, parent_session, seed_length, delegation_depth, sandbox_mode, approval_policy, revision, generation)
|
(id, version, created_at, cwd, parent_session, seed_length, delegation_depth, sandbox_mode, approval_policy, revision, generation)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
`).run(
|
`).run(...SessionQuerySqlite._headerBindings(entry.header), revision, generation)
|
||||||
entry.header.id,
|
|
||||||
entry.header.version,
|
|
||||||
entry.header.createdAt,
|
|
||||||
entry.header.cwd ?? null,
|
|
||||||
entry.header.parentSession ?? null,
|
|
||||||
entry.header.seedLength ?? null,
|
|
||||||
entry.header.delegationDepth ?? null,
|
|
||||||
entry.header.sandboxMode ?? null,
|
|
||||||
entry.header.approvalPolicy ?? null,
|
|
||||||
revision,
|
|
||||||
generation,
|
|
||||||
)
|
|
||||||
const insert = db.prepare(`
|
const insert = db.prepare(`
|
||||||
INSERT INTO persisted_docs (text, session_id, seq, type, time, surface, codepoint_length)
|
INSERT INTO persisted_docs (text, session_id, seq, type, time, surface, codepoint_length)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
@@ -575,20 +580,7 @@ export class SessionQuerySqlite extends SessionQueryService {
|
|||||||
INSERT INTO temp.live_sessions
|
INSERT INTO temp.live_sessions
|
||||||
(id, version, created_at, cwd, parent_session, seed_length, delegation_depth, sandbox_mode, approval_policy, fingerprint, persisted, generation)
|
(id, version, created_at, cwd, parent_session, seed_length, delegation_depth, sandbox_mode, approval_policy, fingerprint, persisted, generation)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
`).run(
|
`).run(...SessionQuerySqlite._headerBindings(entry.header), entry.fingerprint, persisted ? 1 : 0, generation)
|
||||||
entry.header.id,
|
|
||||||
entry.header.version,
|
|
||||||
entry.header.createdAt,
|
|
||||||
entry.header.cwd ?? null,
|
|
||||||
entry.header.parentSession ?? null,
|
|
||||||
entry.header.seedLength ?? null,
|
|
||||||
entry.header.delegationDepth ?? null,
|
|
||||||
entry.header.sandboxMode ?? null,
|
|
||||||
entry.header.approvalPolicy ?? null,
|
|
||||||
entry.fingerprint,
|
|
||||||
persisted ? 1 : 0,
|
|
||||||
generation,
|
|
||||||
)
|
|
||||||
const insert = db.prepare(`
|
const insert = db.prepare(`
|
||||||
INSERT INTO temp.live_docs (text, session_id, seq, type, time, surface, codepoint_length)
|
INSERT INTO temp.live_docs (text, session_id, seq, type, time, surface, codepoint_length)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
|||||||
Reference in New Issue
Block a user