{"record":{"id":"d751417f18e9363c","repo":"ruvnet/ruflo","slug":"aggregate-called-basic-translation-only","errorCode":null,"errorMessage":"aggregate() called — basic translation only","messagePattern":"aggregate\\(\\) called — basic translation only","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ruflo/src/ruvocal/src/lib/server/database/postgres.ts","lineNumber":481,"sourceCode":"\t\treturn result.rows[0]?.count ?? 0;\n\t}\n\n\tasync distinct(\n\t\tfield: string,\n\t\tfilter: Record<string, unknown> = {}\n\t): Promise<unknown[]> {\n\t\tconst col = `\"${snakeCase(field)}\"`;\n\t\tconst w = filterToWhere(filter);\n\t\tconst sql = `SELECT DISTINCT ${col} FROM \"${this.tableName}\" WHERE ${w.text}`;\n\t\tconst result = await this.pool.query(sql, w.values);\n\t\treturn result.rows.map((r) => r[snakeCase(field)]);\n\t}\n\n\tasync aggregate(pipeline: Record<string, unknown>[]): Promise<T[]> {\n\t\t// Basic aggregation support — handle common patterns\n\t\t// For complex pipelines, we'd need a full translator.\n\t\t// For now, log a warning and return empty.\n\t\tlogger.warn(\n\t\t\t{ pipeline, table: this.tableName },\n\t\t\t\"aggregate() called — basic translation only\"\n\t\t);\n\t\treturn [];\n\t}\n\n\tasync createIndex(\n\t\t_spec: Record<string, unknown>,\n\t\t_options?: Record<string, unknown>\n\t): Promise<void> {\n\t\t// Indexes are pre-created in the migration. This is a no-op.\n\t}\n\n\tasync findOneAndUpdate(\n\t\tfilter: Record<string, unknown>,\n\t\tupdate: Record<string, unknown>,\n\t\toptions?: { upsert?: boolean; returnDocument?: \"before\" | \"after\" }\n\t): Promise<{ value: T | null }> {","sourceCodeStart":463,"sourceCodeEnd":499,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/ruflo/src/ruvocal/src/lib/server/database/postgres.ts#L463-L499","documentation":"Log warning in the Postgres collection's aggregate: MongoDB-style aggregation pipelines are only partially translated to SQL, so complex/untranslatable stages are approximated or ignored — callers must not rely on full aggregation semantics.","triggerScenarios":"Thrown at ruflo/src/ruvocal/src/lib/server/database/postgres.ts:481 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Avoid aggregate() on this adapter, or extend the translation layer to support the aggregation pipeline stages used."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}