Load Fix
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 31s
Build and Push Docker Images / build-frontend (push) Successful in 16s

This commit is contained in:
2026-02-16 13:56:45 +01:00
parent 2621cc0d8d
commit f26d6bd4f3

View File

@@ -357,7 +357,18 @@ export default async function resourceRoutes(server: FastifyInstance) {
for (const colName of distinctColumns.split(",").map(c => c.trim())) {
const col = (table as any)[colName];
if (!col) continue;
const dRows = await server.db.select({ v: col }).from(table).where(whereCond);
let distinctQuery = server.db.select({ v: col }).from(table).$dynamic();
if (config.mtoLoad) {
config.mtoLoad.forEach(rel => {
const relConfig = resourceConfig[rel + "s"] || resourceConfig[rel];
if (!relConfig) return;
const relTable = relConfig.table;
if (relTable !== table) {
distinctQuery = distinctQuery.leftJoin(relTable, eq(table[rel], relTable.id));
}
});
}
const dRows = await distinctQuery.where(whereCond);
distinctValues[colName] = [...new Set(dRows.map(r => r.v).filter(v => v != null && v !== ""))].sort();
}
}