refactor(session-query-sqlite): bind the header columns once
Both session upserts write the same eight header columns and differ only in what they append; the agent_preset column made the pair long enough for the duplication gate to flag it.
This commit is contained in:
@@ -556,14 +556,7 @@ export class SessionQuerySqlite extends SessionQueryService {
|
|||||||
(id, version, created_at, cwd, parent_session, seed_length, delegation_depth, agent_preset, revision, generation)
|
(id, version, created_at, cwd, parent_session, seed_length, delegation_depth, agent_preset, revision, generation)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
`).run(
|
`).run(
|
||||||
entry.header.id,
|
...headerBindings(entry.header),
|
||||||
entry.header.version,
|
|
||||||
entry.header.createdAt,
|
|
||||||
entry.header.cwd ?? null,
|
|
||||||
entry.header.parentSession ?? null,
|
|
||||||
entry.header.seedLength ?? null,
|
|
||||||
entry.header.delegationDepth ?? null,
|
|
||||||
entry.header.agentPreset ?? null,
|
|
||||||
revision,
|
revision,
|
||||||
generation,
|
generation,
|
||||||
)
|
)
|
||||||
@@ -593,14 +586,7 @@ export class SessionQuerySqlite extends SessionQueryService {
|
|||||||
(id, version, created_at, cwd, parent_session, seed_length, delegation_depth, agent_preset, fingerprint, persisted, generation)
|
(id, version, created_at, cwd, parent_session, seed_length, delegation_depth, agent_preset, fingerprint, persisted, generation)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
`).run(
|
`).run(
|
||||||
entry.header.id,
|
...headerBindings(entry.header),
|
||||||
entry.header.version,
|
|
||||||
entry.header.createdAt,
|
|
||||||
entry.header.cwd ?? null,
|
|
||||||
entry.header.parentSession ?? null,
|
|
||||||
entry.header.seedLength ?? null,
|
|
||||||
entry.header.delegationDepth ?? null,
|
|
||||||
entry.header.agentPreset ?? null,
|
|
||||||
entry.fingerprint,
|
entry.fingerprint,
|
||||||
persisted ? 1 : 0,
|
persisted ? 1 : 0,
|
||||||
generation,
|
generation,
|
||||||
@@ -753,6 +739,25 @@ export class SessionQuerySqlite extends SessionQueryService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The header columns both session upserts bind, in the order their INSERT
|
||||||
|
* lists them. The two statements differ only in what they append after these.
|
||||||
|
* @param header - the session header being written.
|
||||||
|
* @returns one bound value per header column.
|
||||||
|
*/
|
||||||
|
function headerBindings(header: SessionHeader): (string | number | null)[] {
|
||||||
|
return [
|
||||||
|
header.id,
|
||||||
|
header.version,
|
||||||
|
header.createdAt,
|
||||||
|
header.cwd ?? null,
|
||||||
|
header.parentSession ?? null,
|
||||||
|
header.seedLength ?? null,
|
||||||
|
header.delegationDepth ?? null,
|
||||||
|
header.agentPreset ?? null,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
function selectedDocumentsSql(): { sql: string } {
|
function selectedDocumentsSql(): { sql: string } {
|
||||||
return {
|
return {
|
||||||
sql: `WITH candidates AS (
|
sql: `WITH candidates AS (
|
||||||
|
|||||||
Reference in New Issue
Block a user