[apps] possible inventions fix

This commit is contained in:
Devin Zuczek
2026-10-16 12:46:55 -04:00
parent 5eac7480ae
commit 6d905e1811
+4 -3
View File
@@ -1278,10 +1278,11 @@ export async function getInventionsByIds(
inventionIds: number[] inventionIds: number[]
): Promise<SavedInvention[]> { ): Promise<SavedInvention[]> {
if (inventionIds.length === 0) return [] if (inventionIds.length === 0) return []
const placeholders = inventionIds.map((_, i) => `?${i + 1}`).join(', ') // One bound JSON array rather than a placeholder per id: D1 caps a statement at 100
// bound variables, and the top-today window or a big collection easily passes that.
const { results } = await db const { results } = await db
.prepare(`SELECT data FROM invention WHERE id IN (${placeholders})`) .prepare(`SELECT data FROM invention WHERE id IN (SELECT value FROM json_each(?1))`)
.bind(...inventionIds) .bind(JSON.stringify(inventionIds))
.all<InventionRow>() .all<InventionRow>()
const byId = new Map<number, SavedInvention>() const byId = new Map<number, SavedInvention>()